[RFC] sim: Fix signal variable for `sh`

Message ID 20250306200251.GB15128@lug-owl.de
State New
Headers
Series [RFC] sim: Fix signal variable for `sh` |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 warning Skipped upon request
linaro-tcwg-bot/tcwg_gdb_build--master-arm fail Patch failed to apply

Commit Message

Jan-Benedict Glaw March 6, 2025, 8:02 p.m. UTC
  Hi!

I had a build running with a very recent GCC, which broke due to a
mismatched sighandler_t:

depbase=`echo sh/interp.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
/var/lib/laminar/run/gdb-sh-elf/53/local-toolchain-install/bin/gcc -DHAVE_CONFIG_H -I.  -I./../gnulib/import -I../gnulib/import -I./.. -I./../include -I../bfd -I.. -Ish -I./sh -DWITH_HW=1 -DHAVE_DV_SOCKSER -DDEFAULT_INLINE=0   -I./common -DSIM_TOPDIR_BUILD  -Werror -Wall -Wpointer-arith -Wno-unused -Wunused-value -Wunused-variable -Wunused-function -Wno-switch -Wno-char-subscripts -Wempty-body -Wunused-but-set-parameter -Wunused-but-set-variable -Wno-sign-compare -Wno-error=maybe-uninitialized -Wimplicit-fallthrough=5 -Wduplicated-cond -Wshadow=local -Wmissing-declarations -Wdeclaration-after-statement -Wdeprecated-non-prototype -Wimplicit-function-declaration -Wimplicit-int -Wincompatible-pointer-types -Wint-conversion -Wmisleading-indentation -Wmissing-parameter-type -Wmissing-prototypes -Wold-style-declaration -Wold-style-definition -Wpointer-sign -Wreturn-mismatch -Wreturn-type -Wshift-negative-value -Wstrict-prototypes -Wno-enum-conversion -Wformat -Wformat-nonliteral   -g -O2   -MT sh/interp.o -MD -MP -MF $depbase.Tpo -c -o sh/interp.o sh/interp.c &&\
mv -f $depbase.Tpo $depbase.Po
sh/interp.c: In function 'sim_resume':
sh/interp.c:1731:12: error: assignment to 'void (*)(void)' from incompatible pointer type '__sighandler_t' {aka 'void (*)(int)'} [-Wincompatible-pointer-types]
 1731 |   prev_fpe = signal (SIGFPE, SIG_IGN);
      |            ^
In file included from ./../gnulib/import/signal.h:52,
                 from sh/interp.c:27:
/usr/include/signal.h:72:16: note: '__sighandler_t' declared here
   72 | typedef void (*__sighandler_t) (int);
      |                ^~~~~~~~~~~~~~
sh/interp.c:1867:19: error: passing argument 2 of 'signal' from incompatible pointer type [-Wincompatible-pointer-types]
 1867 |   signal (SIGFPE, prev_fpe);
      |                   ^~~~~~~~
      |                   |
      |                   void (*)(void)
/usr/include/signal.h:88:57: note: expected '__sighandler_t' {aka 'void (*)(int)'} but argument is of type 'void (*)(void)'
   88 | extern __sighandler_t signal (int __sig, __sighandler_t __handler)
      |                                          ~~~~~~~~~~~~~~~^~~~~~~~~
/usr/include/signal.h:72:16: note: '__sighandler_t' declared here
   72 | typedef void (*__sighandler_t) (int);
      |                ^~~~~~~~~~~~~~
make[2]: *** [Makefile:4250: sh/interp.o] Error 1
make[2]: Leaving directory '/var/lib/laminar/run/gdb-sh-elf/53/binutils-gdb/sim'
make[1]: *** [Makefile:3235: all] Error 2
make[1]: Leaving directory '/var/lib/laminar/run/gdb-sh-elf/53/binutils-gdb/sim'
make: *** [Makefile:10873: all-sim] Error 2



This would fix it:


...or change to sigaction()? And/or go for RETSIGTYPE?

Thanks,
  Jan-Benedict

--
  

Comments

Tom Tromey March 6, 2025, 9:13 p.m. UTC | #1
>>>>> "Jan-Benedict" == Jan-Benedict Glaw <jbglaw@lug-owl.de> writes:

Jan-Benedict> This would fix it:
[...]

This is ok.  Thanks.  If you have commit access you can check it in.

Approved-By: Tom Tromey <tom@tromey.com>


Jan-Benedict> ...or change to sigaction()? And/or go for RETSIGTYPE?

I'm a little surprised that nothing seems to be using sighandler_t.
Leaving it as signal (and not switching to sigaction) seems fine FWIW.

Tom
  
Jan-Benedict Glaw March 7, 2025, 9:36 a.m. UTC | #2
On Thu, 2025-03-06 14:13:23 -0700, Tom Tromey <tom@tromey.com> wrote:
> >>>>> "Jan-Benedict" == Jan-Benedict Glaw <jbglaw@lug-owl.de> writes:
> 
> Jan-Benedict> This would fix it:
> [...]
> 
> This is ok.  Thanks.  If you have commit access you can check it in.

Thanks, committed & pushed.

MfG, JBG

--
  

Patch

diff --git a/sim/sh/interp.c b/sim/sh/interp.c
index 379b44f82ba..c8c2a7429ce 100644
--- a/sim/sh/interp.c
+++ b/sim/sh/interp.c
@@ -1712,7 +1712,7 @@  sim_resume (SIM_DESC sd, int step, int siggnal)
   register int endianw = global_endianw;
 
   int tick_start = get_now ();
-  void (*prev_fpe) ();
+  void (*prev_fpe) (int);
 
   register unsigned short *jump_table = sh_jump_table;