changeset 27480:63b417917f5e

remove some obsolete signal handling functions * quit.h, quit.cc (octave_exception): Delete enum declaration. (octave_exception_state, octave_exit_exception_status, octave_exit_exception_safe_to_return): Delete variables and all uses. (octave_throw_interrupt_exception, octave_throw_execution_exception, octave_throw_bad_alloc, octave_throw_exit_exception, octave_rethrow_exception): Delete functions and all uses. * cquit.c: Delete * liboctave/util/module.mk: Update.
author John W. Eaton <jwe@octave.org>
date Sun, 06 Oct 2019 16:30:35 -0400
parents e8c417f6ef83
children 458adc344819
files libinterp/corefcn/interpreter.cc libinterp/parse-tree/pt-eval.cc liboctave/util/cquit.c liboctave/util/module.mk liboctave/util/quit.cc liboctave/util/quit.h
diffstat 6 files changed, 22 insertions(+), 199 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/interpreter.cc	Mon Oct 07 10:55:51 2019 -0400
+++ b/libinterp/corefcn/interpreter.cc	Sun Oct 06 16:30:35 2019 -0400
@@ -335,7 +335,7 @@
     verror_with_cfn (fmt, args);
     va_end (args);
 
-    octave_throw_execution_exception ();
+    throw execution_exception ();
   }
 
   OCTAVE_NORETURN static void
@@ -346,7 +346,7 @@
     verror_with_id_cfn (id, fmt, args);
     va_end (args);
 
-    octave_throw_execution_exception ();
+    throw execution_exception ();
   }
 
   static void initialize_error_handlers (void)
@@ -886,7 +886,6 @@
 
     octave_signal_hook = respond_to_pending_signals;
     octave_interrupt_hook = nullptr;
-    octave_bad_alloc_hook = nullptr;
 
     catch_interrupts ();
 
@@ -930,7 +929,6 @@
 
     octave_signal_hook = respond_to_pending_signals;
     octave_interrupt_hook = nullptr;
-    octave_bad_alloc_hook = nullptr;
 
     catch_interrupts ();
 
@@ -984,7 +982,6 @@
 
     octave_signal_hook = respond_to_pending_signals;
     octave_interrupt_hook = nullptr;
-    octave_bad_alloc_hook = nullptr;
 
     catch_interrupts ();
 
@@ -1678,7 +1675,6 @@
     can_interrupt = true;
     octave_interrupt_state = 0;
     octave_signal_caught = 0;
-    octave_exception_state = octave_no_exception;
     octave_restore_signal_mask ();
     catch_interrupts ();
   }
--- a/libinterp/parse-tree/pt-eval.cc	Mon Oct 07 10:55:51 2019 -0400
+++ b/libinterp/parse-tree/pt-eval.cc	Sun Oct 06 16:30:35 2019 -0400
@@ -659,7 +659,7 @@
         // exception occurred, not just throwing an
         // execution exception.
         if (execution_error)
-          octave_throw_execution_exception ();
+          throw execution_exception ();
       }
 
     return retval;
@@ -740,7 +740,7 @@
         // exception occurred, not just throwing an
         // execution exception.
         if (execution_error)
-          octave_throw_execution_exception ();
+          throw execution_exception ();
       }
 
     return retval;
--- a/liboctave/util/cquit.c	Mon Oct 07 10:55:51 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
-
-Copyright (C) 2003-2019 John W. Eaton
-
-This file is part of Octave.
-
-Octave is free software: you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-Octave is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Octave; see the file COPYING.  If not, see
-<https://www.gnu.org/licenses/>.
-
-*/
-
-#if defined (HAVE_CONFIG_H)
-#  include "config.h"
-#endif
-
-#include <signal.h>
-#include <string.h>
-
-#include "quit.h"
-
-sig_atomic_t octave_interrupt_state = 0;
-
-sig_atomic_t octave_exception_state = 0;
-
-#if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC)
-#  pragma GCC diagnostic push
-#  pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#endif
-
-sig_atomic_t octave_exit_exception_status = 0;
-
-sig_atomic_t octave_exit_exception_safe_to_return = 0;
-
-#if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC)
-#  pragma GCC diagnostic pop
-#endif
-
-volatile sig_atomic_t octave_signal_caught = 0;
--- a/liboctave/util/module.mk	Mon Oct 07 10:55:51 2019 -0400
+++ b/liboctave/util/module.mk	Sun Oct 06 16:30:35 2019 -0400
@@ -55,7 +55,6 @@
   %reldir%/f2c-main.c \
   %reldir%/lo-cutils.c \
   %reldir%/blaswrap.c \
-  %reldir%/cquit.c \
   %reldir%/f77-fcn.c \
   %reldir%/lo-error.c \
   %reldir%/oct-rl-edit.c \
--- a/liboctave/util/quit.cc	Mon Oct 07 10:55:51 2019 -0400
+++ b/liboctave/util/quit.cc	Sun Oct 06 16:30:35 2019 -0400
@@ -32,9 +32,12 @@
 
 #include "quit.h"
 
+sig_atomic_t octave_interrupt_state = 0;
+
+volatile sig_atomic_t octave_signal_caught = 0;
+
 void (*octave_signal_hook) (void) = nullptr;
 void (*octave_interrupt_hook) (void) = nullptr;
-void (*octave_bad_alloc_hook) (void) = nullptr;
 
 namespace octave
 {
@@ -93,105 +96,18 @@
 void
 octave_handle_signal (void)
 {
+  octave_signal_caught = 0;
+
   if (octave_signal_hook)
     octave_signal_hook ();
 
   if (octave_interrupt_state > 0)
     {
       octave_interrupt_state = -1;
-      octave_throw_interrupt_exception ();
+
+      if (octave_interrupt_hook)
+        octave_interrupt_hook ();
+
+      throw octave::interrupt_exception ();
     }
 }
-
-void
-clean_up_and_exit (int exit_status, bool /* safe_to_return */)
-{
-  exit (exit_status);
-}
-
-void
-octave_throw_interrupt_exception (void)
-{
-  if (octave_interrupt_hook)
-    octave_interrupt_hook ();
-
-  throw octave::interrupt_exception ();
-}
-
-void
-octave_throw_execution_exception (void)
-{
-  // FIXME: would a hook function be useful here?
-
-  octave_exception_state = octave_exec_exception;
-
-  throw octave::execution_exception ();
-}
-
-void
-octave_throw_bad_alloc (void)
-{
-  if (octave_bad_alloc_hook)
-    octave_bad_alloc_hook ();
-
-  octave_exception_state = octave_alloc_exception;
-
-  throw std::bad_alloc ();
-}
-
-void
-octave_throw_exit_exception (int exit_status, int safe_to_return)
-{
-  octave_exception_state = octave_quit_exception;
-
-#if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC)
-#  pragma GCC diagnostic push
-#  pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#endif
-
-  throw octave::exit_exception (exit_status, safe_to_return);
-
-#if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC)
-#  pragma GCC diagnostic pop
-#endif
-}
-
-void
-octave_rethrow_exception (void)
-{
-  if (octave_interrupt_state)
-    {
-      octave_interrupt_state = -1;
-      octave_throw_interrupt_exception ();
-    }
-  else
-    {
-      switch (octave_exception_state)
-        {
-        case octave_exec_exception:
-          octave_throw_execution_exception ();
-          break;
-
-        case octave_alloc_exception:
-          octave_throw_bad_alloc ();
-          break;
-
-#if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC)
-#  pragma GCC diagnostic push
-#  pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#endif
-
-        case octave_quit_exception:
-          octave_throw_exit_exception (octave_exit_exception_status,
-                                       octave_exit_exception_safe_to_return);
-          break;
-
-#if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC)
-#  pragma GCC diagnostic pop
-#endif
-
-        default:
-          break;
-        }
-    }
-}
--- a/liboctave/util/quit.h	Mon Oct 07 10:55:51 2019 -0400
+++ b/liboctave/util/quit.h	Sun Oct 06 16:30:35 2019 -0400
@@ -197,14 +197,6 @@
 
 #endif
 
-enum octave_exception
-{
-  octave_no_exception = 0,
-  octave_exec_exception = 1,
-  octave_alloc_exception = 3,
-  octave_quit_exception = 4
-};
-
 /*
   > 0: interrupt pending
     0: no interrupt pending
@@ -212,43 +204,16 @@
 */
 OCTAVE_API extern sig_atomic_t octave_interrupt_state;
 
-OCTAVE_API extern sig_atomic_t octave_exception_state;
-
-OCTAVE_DEPRECATED (4.4, "see the Octave documentation for other options")
-OCTAVE_API extern sig_atomic_t octave_exit_exception_status;
-
-OCTAVE_DEPRECATED (4.4, "see the Octave documentation for other options")
-OCTAVE_API extern sig_atomic_t octave_exit_exception_safe_to_return;
-
 OCTAVE_API extern volatile sig_atomic_t octave_signal_caught;
 
 OCTAVE_API extern void octave_handle_signal (void);
 
-OCTAVE_NORETURN OCTAVE_API extern void octave_throw_interrupt_exception (void);
-
-OCTAVE_NORETURN OCTAVE_API extern void octave_throw_execution_exception (void);
-
-OCTAVE_NORETURN OCTAVE_API extern void octave_throw_bad_alloc (void);
-
-OCTAVE_DEPRECATED (4.4, "see the Octave documentation for other options")
-OCTAVE_NORETURN OCTAVE_API extern void
-octave_throw_exit_exception (int exit_status, int safe_to_return);
-
-OCTAVE_API extern void octave_rethrow_exception (void);
-
 #if defined (__cplusplus)
 
-OCTAVE_DEPRECATED (4.4, "see the Octave documentation for other options")
-extern OCTAVE_API void
-clean_up_and_exit (int exit_status, bool safe_to_return = false);
-
 inline void octave_quit (void)
 {
   if (octave_signal_caught)
-    {
-      octave_signal_caught = 0;
-      octave_handle_signal ();
-    }
+    octave_handle_signal ();
 };
 
 #define OCTAVE_QUIT octave_quit ()
@@ -259,21 +224,18 @@
   do                                            \
     {                                           \
       if (octave_signal_caught)                 \
-        {                                       \
-          octave_signal_caught = 0;             \
-          octave_handle_signal ();              \
-        }                                       \
+        octave_handle_signal ();                \
     }                                           \
   while (0)
+
 #endif
 
 /* The following macros are obsolete.  Interrupting immediately by
    calling siglongjmp or similar from a signal handler is asking for
-   trouble.  We need another way to handle that situation.  Rather
-   than remove them, however, please leave them in place until we can
-   either find a replacement or determine that a given block of code
-   does not need special treatment.  They are defined to create a
-   dummy do-while block to match the previous definitions.  */
+   trouble.  Rather than remove them, however, please leave them in
+   place so that old code that uses them will continue to compile.  They
+   are defined to create a dummy do-while block to match the previous
+   definitions.  */
 
 #define BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE     \
   do                                                    \
@@ -305,7 +267,6 @@
 
 extern OCTAVE_API void (*octave_signal_hook) (void);
 extern OCTAVE_API void (*octave_interrupt_hook) (void);
-extern OCTAVE_API void (*octave_bad_alloc_hook) (void);
 
 #endif