]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: Use sighandler_t everywhere
authorPedro Alves <palves@redhat.com>
Thu, 27 Aug 2015 12:26:23 +0000 (13:26 +0100)
committerPedro Alves <palves@redhat.com>
Thu, 27 Aug 2015 12:26:23 +0000 (13:26 +0100)
This fixes 14 build errors like these in C++ mode:

 src/gdb/extension.c: In function ‘void install_sigint_handler(const signal_handler*)’:
 src/gdb/extension.c:698:41: error: invalid conversion from ‘void (*)()’ to ‘__sighandler_t {aka void (*)(int)}’ [-fpermissive]
    signal (SIGINT, handler_state->handler);
  ^
 In file included from build-gnulib/import/signal.h:52:0,
  from ../../src/gdb/extension.c:24:
 /usr/include/signal.h:102:23: error:   initializing argument 2 of ‘void (* signal(int, __sighandler_t))(int)’ [-fpermissive]
  extern __sighandler_t signal (int __sig, __sighandler_t __handler)
^

Instead of this everywhere:

 -  RETSIGTYPE (*handle_sigint_for_compare) () = handle_sigint;
 +  RETSIGTYPE (*handle_sigint_for_compare) (int) = handle_sigint;

Use sighandler_t (a GNU extension).  That's OK to use unconditionaly
because gnulib's signal.h replacement makes sure that it is available.

gdb/ChangeLog:
2015-08-27  Pedro Alves  <palves@redhat.com>

* cp-support.c (gdb_demangle): Use sighandler_t.  Remove cast.
* extension-priv.h: Include signal.h.
(struct signal_handler) <handler>: Change type to sighandler_t.
* extension.c (install_gdb_sigint_handler): Use sighandler_t.
* inflow.c (sigint_ours, sigquit_ours): Change type to
sighandler_t.
(child_terminal_inferior): Remove casts.
(child_terminal_ours_1, new_tty): Use sighandler_t.  Remove casts.
(osig): Change type to sighandler_t.
* nto-procfs.c (ofunc): Change type to sighandler_t.
(procfs_wait): Remove casts.
* remote-m32r-sdi.c (m32r_wait, m32r_load): Use sighandler_t.
* remote-sim.c (gdbsim_wait): Use sighandler_t.
* utils.c (wait_to_die_with_timeout): Use sighandler_t.

gdb/ChangeLog
gdb/cp-support.c
gdb/extension-priv.h
gdb/extension.c
gdb/inflow.c
gdb/nto-procfs.c
gdb/remote-m32r-sdi.c
gdb/remote-sim.c
gdb/utils.c

index db3b1b96483a67b8c7c9da215bd43a11a496dab3..8d40deede0982072a15c44eace8c33017442271b 100644 (file)
@@ -1,3 +1,20 @@
+2015-08-27  Pedro Alves  <palves@redhat.com>
+
+       * cp-support.c (gdb_demangle): Use sighandler_t.  Remove cast.
+       * extension-priv.h: Include signal.h.
+       (struct signal_handler) <handler>: Change type to sighandler_t.
+       * extension.c (install_gdb_sigint_handler): Use sighandler_t.
+       * inflow.c (sigint_ours, sigquit_ours): Change type to
+       sighandler_t.
+       (child_terminal_inferior): Remove casts.
+       (child_terminal_ours_1, new_tty): Use sighandler_t.  Remove casts.
+       (osig): Change type to sighandler_t.
+       * nto-procfs.c (ofunc): Change type to sighandler_t.
+       (procfs_wait): Remove casts.
+       * remote-m32r-sdi.c (m32r_wait, m32r_load): Use sighandler_t.
+       * remote-sim.c (gdbsim_wait): Use sighandler_t.
+       * utils.c (wait_to_die_with_timeout): Use sighandler_t.
+
 2015-08-27  Pedro Alves  <palves@redhat.com>
 
        * gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Add signal-h.
index 3995bcc32623b4bd33d0e70f380241a706785489..d3e26ad35b7c577f3abaf2b1d3072ea47e646af7 100644 (file)
@@ -1535,7 +1535,7 @@ gdb_demangle (const char *name, int options)
 #if defined (HAVE_SIGACTION) && defined (SA_RESTART)
   struct sigaction sa, old_sa;
 #else
-  void (*ofunc) ();
+  sighandler_t ofunc;
 #endif
   static int core_dump_allowed = -1;
 
@@ -1559,7 +1559,7 @@ gdb_demangle (const char *name, int options)
 #endif
       sigaction (SIGSEGV, &sa, &old_sa);
 #else
-      ofunc = (void (*)()) signal (SIGSEGV, gdb_demangle_signal_handler);
+      ofunc = signal (SIGSEGV, gdb_demangle_signal_handler);
 #endif
 
       crash_signal = SIGSETJMP (gdb_demangle_jmp_buf);
index d0242e28f296df24a667e89e85abcbee35ccad35..dd7326e2c72e6bb68b014a0a292903c9b7b2de6f 100644 (file)
@@ -22,6 +22,7 @@
 #define EXTENSION_PRIV_H
 
 #include "extension.h"
+#include <signal.h>
 
 /* The return code for some API calls.  */
 
@@ -329,7 +330,7 @@ struct signal_handler
   int handler_saved;
 
   /* The signal handler.  */
-  RETSIGTYPE (*handler) ();
+  sighandler_t handler;
 };
 
 /* State necessary to restore the currently active extension language
index dac203b0dd2b5cb9b72e41537bcae7db672faa70..1b5365a1d66d65be565fb5e8a71f0cfcf0256235 100644 (file)
@@ -707,7 +707,7 @@ static void
 install_gdb_sigint_handler (struct signal_handler *previous)
 {
   /* Save here to simplify comparison.  */
-  RETSIGTYPE (*handle_sigint_for_compare) () = handle_sigint;
+  sighandler_t handle_sigint_for_compare = handle_sigint;
 
   previous->handler = signal (SIGINT, handle_sigint);
   if (previous->handler != handle_sigint_for_compare)
index a9db6506845b64bc5141b02c65f82831d2ad993b..cdc47a05528cf45065ffa0c4a8cb9e103ff7bfc0 100644 (file)
@@ -101,8 +101,8 @@ inferior_process_group (void)
    we save our handlers in these two variables and set SIGINT and SIGQUIT
    to SIG_IGN.  */
 
-static void (*sigint_ours) ();
-static void (*sigquit_ours) ();
+static sighandler_t sigint_ours;
+static sighandler_t sigquit_ours;
 
 /* The name of the tty (from the `tty' command) that we're giving to
    the inferior when starting it up.  This is only (and should only
@@ -319,9 +319,9 @@ child_terminal_inferior (struct target_ops *self)
 
       if (!job_control)
        {
-         sigint_ours = (void (*)()) signal (SIGINT, SIG_IGN);
+         sigint_ours = signal (SIGINT, SIG_IGN);
 #ifdef SIGQUIT
-         sigquit_ours = (void (*)()) signal (SIGQUIT, SIG_IGN);
+         sigquit_ours = signal (SIGQUIT, SIG_IGN);
 #endif
        }
 
@@ -417,13 +417,13 @@ child_terminal_ours_1 (int output_only)
 #ifdef SIGTTOU
       /* Ignore this signal since it will happen when we try to set the
          pgrp.  */
-      void (*osigttou) () = NULL;
+      sighandler_t osigttou = NULL;
 #endif
       int result;
 
 #ifdef SIGTTOU
       if (job_control)
-       osigttou = (void (*)()) signal (SIGTTOU, SIG_IGN);
+       osigttou = signal (SIGTTOU, SIG_IGN);
 #endif
 
       xfree (tinfo->ttystate);
@@ -711,9 +711,9 @@ new_tty (void)
   tty = open ("/dev/tty", O_RDWR);
   if (tty > 0)
     {
-      void (*osigttou) ();
+      sighandler_t osigttou;
 
-      osigttou = (void (*)()) signal (SIGTTOU, SIG_IGN);
+      osigttou = signal (SIGTTOU, SIG_IGN);
       ioctl (tty, TIOCNOTTY, 0);
       close (tty);
       signal (SIGTTOU, osigttou);
@@ -788,7 +788,7 @@ pass_signal (int signo)
 #endif
 }
 
-static void (*osig) ();
+static sighandler_t osig;
 static int osig_set;
 
 void
@@ -799,7 +799,7 @@ set_sigint_trap (void)
 
   if (inf->attach_flag || tinfo->run_terminal)
     {
-      osig = (void (*)()) signal (SIGINT, pass_signal);
+      osig = signal (SIGINT, pass_signal);
       osig_set = 1;
     }
   else
index 2d1c49a061c94e7fc16e332568af017eb99d32f6..20b05be217a4497cd15e728c7c69af0ffe745bfc 100644 (file)
@@ -47,7 +47,7 @@
 
 int ctl_fd;
 
-static void (*ofunc) ();
+static sighandler_t ofunc;
 
 static procfs_run run;
 
@@ -735,7 +735,7 @@ procfs_wait (struct target_ops *ops,
   devctl (ctl_fd, DCMD_PROC_STATUS, &status, sizeof (status), 0);
   while (!(status.flags & _DEBUG_FLAG_ISTOP))
     {
-      ofunc = (void (*)()) signal (SIGINT, nto_handle_sigint);
+      ofunc = signal (SIGINT, nto_handle_sigint);
       sigwaitinfo (&set, &info);
       signal (SIGINT, ofunc);
       devctl (ctl_fd, DCMD_PROC_STATUS, &status, sizeof (status), 0);
index bb07e4e971fd96e1aea0a7adbd3bc848db6bc8c6..e67f9d43f721294bc5afd2dfb7b17f2422ced304 100644 (file)
@@ -701,7 +701,7 @@ static ptid_t
 m32r_wait (struct target_ops *ops,
           ptid_t ptid, struct target_waitstatus *status, int options)
 {
-  static RETSIGTYPE (*prev_sigint) ();
+  static sighandler_t prev_sigint;
   unsigned long bp_addr, pc_addr;
   int ib_breakpoints;
   long i;
@@ -1249,7 +1249,7 @@ m32r_load (struct target_ops *self, const char *args, int from_tty)
   int nostart;
   struct timeval start_time, end_time;
   unsigned long data_count;    /* Number of bytes transferred to memory.  */
-  static RETSIGTYPE (*prev_sigint) ();
+  static sighandler_t prev_sigint;
 
   /* for direct tcp connections, we can do a fast binary download.  */
   quiet = 0;
index b2288629a79f5b1b9d9202e896fe0d3c58b71f83..8bd1a65528bec2d99052d9c8313a8878947eb306 100644 (file)
@@ -976,7 +976,7 @@ gdbsim_wait (struct target_ops *ops,
             ptid_t ptid, struct target_waitstatus *status, int options)
 {
   struct sim_inferior_data *sim_data;
-  static RETSIGTYPE (*prev_sigint) ();
+  static sighandler_t prev_sigint;
   int sigrc = 0;
   enum sim_stop reason = sim_running;
 
index fdc486dc1b56c1c4dcd69ea8f066ad0c7dff7829..3ce88b957ba4fe4cb0b7e16092a4aa4e98fcf765 100644 (file)
@@ -3302,9 +3302,9 @@ wait_to_die_with_timeout (pid_t pid, int *status, int timeout)
       sa.sa_flags = 0;
       sigaction (SIGALRM, &sa, &old_sa);
 #else
-      void (*ofunc) ();
+      sighandler_t ofunc;
 
-      ofunc = (void (*)()) signal (SIGALRM, sigalrm_handler);
+      ofunc = signal (SIGALRM, sigalrm_handler);
 #endif
 
       alarm (timeout);