Mercurial > octave
annotate liboctave/cruft/misc/quit.h @ 20791:f7084eae3318
maint: Use Octave coding conventions for #if statements.
* mk-opts.pl, dialog.h, find-files-dialog.h, find-files-model.h,
file-editor-tab.h, octave-qscintilla.h, octave-txt-lexer.h, main-window.h,
octave-cmd.h, octave-dock-widget.h, octave-gui.h, thread-manager.h,
workspace-model.h, workspace-view.h, builtins.h, Cell.h, bitfcns.cc,
c-file-ptr-stream.h, cdisplay.h, comment-list.h, cutils.h, data.h, debug.h,
defaults.in.h, defun-dld.h, defun-int.h, defun.h, dirfns.h, display.h,
dynamic-ld.h, error.h, event-queue.h, file-io.h, filter.cc, getrusage.cc,
gl-render.h, gl2ps-renderer.h, graphics.in.h, gripes.h, help.h, hook-fcn.h,
input.h, jit-ir.h, jit-typeinfo.h, jit-util.h, load-path.h, load-save.h,
ls-ascii-helper.h, ls-hdf5.h, ls-mat-ascii.h, ls-mat4.h, ls-mat5.h,
ls-oct-binary.h, ls-oct-text.h, ls-utils.h, oct-errno.h, oct-fstrm.h,
oct-handle.h, oct-hdf5-types.h, oct-hdf5.h, oct-hist.h, oct-iostrm.h,
oct-lvalue.h, oct-map.h, oct-obj.h, oct-prcstrm.h, oct-procbuf.h,
oct-stdstrm.h, oct-stream.h, oct-strstrm.h, oct.h, octave-link.h, pager.h,
pr-output.h, procstream.h, profiler.h, pt-jit.h, sighandlers.cc, sighandlers.h,
siglist.h, sparse-xdiv.h, sparse-xpow.h, symtab.h, syscalls.cc, sysdep.h,
toplev.cc, toplev.h, utils.h, variables.h, workspace-element.h, xdiv.h,
xnorm.h, xpow.h, dmperm.cc, oct-qhull.h, mkbuiltins, oct-conf.in.h,
ov-base-diag.h, ov-base-int.h, ov-base-mat.h, ov-base-scalar.h,
ov-base-sparse.h, ov-base.h, ov-bool-mat.h, ov-bool-sparse.h, ov-bool.h,
ov-builtin.h, ov-cell.h, ov-ch-mat.h, ov-class.h, ov-classdef.h, ov-colon.h,
ov-complex.h, ov-cs-list.h, ov-cx-diag.h, ov-cx-mat.h, ov-cx-sparse.h,
ov-dld-fcn.h, ov-fcn-handle.h, ov-fcn-inline.h, ov-fcn.h, ov-float.h,
ov-flt-complex.h, ov-flt-cx-diag.h, ov-flt-cx-mat.h, ov-flt-re-diag.h,
ov-flt-re-mat.h, ov-int-traits.h, ov-int16.h, ov-int32.h, ov-int64.h,
ov-int8.h, ov-java.h, ov-lazy-idx.h, ov-mex-fcn.h, ov-null-mat.h, ov-perm.h,
ov-range.h, ov-re-diag.h, ov-re-mat.h, ov-re-sparse.h, ov-scalar.h,
ov-str-mat.h, ov-struct.h, ov-type-conv.h, ov-typeinfo.h, ov-uint16.h,
ov-uint32.h, ov-uint64.h, ov-uint8.h, ov-usr-fcn.h, ov.h, octave.h, ops.h,
options-usage.h, lex.h, parse.h, pt-all.h, pt-arg-list.h, pt-array-list.h,
pt-assign.h, pt-binop.h, pt-bp.h, pt-cbinop.h, pt-cell.h, pt-check.h,
pt-classdef.h, pt-cmd.h, pt-colon.h, pt-const.h, pt-decl.h, pt-eval.h,
pt-except.h, pt-exp.h, pt-fcn-handle.h, pt-funcall.h, pt-id.h, pt-idx.h,
pt-jump.h, pt-loop.h, pt-mat.h, pt-misc.h, pt-pr-code.h, pt-select.h,
pt-stmt.h, pt-unop.h, pt-walk.h, pt.h, token.h, version.in.h, Array-util.h,
Array.h, CColVector.h, CDiagMatrix.h, CMatrix.h, CNDArray.h, CRowVector.h,
CSparse.h, DiagArray2.h, MArray-decl.h, MArray-defs.h, MArray.h, MDiagArray2.h,
MSparse.h, Matrix.h, MatrixType.h, PermMatrix.h, Range.h, Sparse.h,
boolMatrix.h, boolNDArray.h, boolSparse.h, chMatrix.h, chNDArray.h,
dColVector.h, dDiagMatrix.h, dMatrix.h, dNDArray.h, dRowVector.h, dSparse.h,
dim-vector.h, fCColVector.h, fCDiagMatrix.h, fCMatrix.h, fCNDArray.h,
fCRowVector.h, fColVector.h, fDiagMatrix.h, fMatrix.h, fNDArray.h,
fRowVector.h, idx-vector.h, int16NDArray.h, int32NDArray.h, int64NDArray.h,
int8NDArray.h, intNDArray.h, uint16NDArray.h, uint32NDArray.h, uint64NDArray.h,
uint8NDArray.h, f77-fcn.h, lo-error.h, quit.h, CmplxAEPBAL.h, CmplxCHOL.h,
CmplxGEPBAL.h, CmplxHESS.h, CmplxLU.h, CmplxQR.h, CmplxQRP.h, CmplxSCHUR.h,
CmplxSVD.h, CollocWt.h, DAE.h, DAEFunc.h, DAERT.h, DAERTFunc.h, DASPK.h,
DASRT.h, DASSL.h, DET.h, EIG.h, LSODE.h, ODE.h, ODEFunc.h, ODES.h, ODESFunc.h,
Quad.h, SparseCmplxCHOL.h, SparseCmplxLU.h, SparseCmplxQR.cc, SparseCmplxQR.h,
SparseQR.h, SparsedbleCHOL.h, SparsedbleLU.h, base-aepbal.h, base-dae.h,
base-de.h, base-lu.h, base-min.h, base-qr.h, bsxfun-decl.h, bsxfun-defs.cc,
bsxfun.h, dbleAEPBAL.h, dbleCHOL.h, dbleGEPBAL.h, dbleHESS.h, dbleLU.h,
dbleQR.h, dbleQRP.h, dbleSCHUR.h, dbleSVD.h, eigs-base.cc, fCmplxAEPBAL.h,
fCmplxCHOL.h, fCmplxGEPBAL.h, fCmplxHESS.h, fCmplxLU.h, fCmplxQR.h,
fCmplxQRP.h, fCmplxSCHUR.h, fCmplxSVD.h, fEIG.h, floatAEPBAL.h, floatCHOL.h,
floatGEPBAL.h, floatHESS.h, floatLU.h, floatQR.h, floatQRP.h, floatSCHUR.h,
floatSVD.h, lo-mappers.cc, lo-mappers.h, lo-specfun.cc, lo-specfun.h,
oct-convn.h, oct-fftw.h, oct-norm.h, oct-rand.h, oct-spparms.h, randmtzig.c,
sparse-base-chol.h, sparse-base-lu.h, sparse-dmsolve.cc, Sparse-diag-op-defs.h,
Sparse-op-decls.h, Sparse-op-defs.h, Sparse-perm-op-defs.h, mk-ops.awk,
mx-base.h, mx-defs.h, mx-ext.h, mx-inlines.cc, mx-op-decl.h, mx-op-defs.h,
sparse-mk-ops.awk, dir-ops.h, file-ops.h, file-stat.h, lo-sysdep.h,
mach-info.h, oct-env.h, oct-group.h, oct-openmp.h, oct-passwd.h,
oct-syscalls.h, oct-time.cc, oct-time.h, oct-uname.h, pathlen.h, sysdir.h,
syswait.h, action-container.h, base-list.h, byte-swap.h, caseless-str.h,
cmd-edit.h, cmd-hist.h, data-conv.h, functor.h, glob-match.h, kpse.cc,
lo-array-gripes.h, lo-cutils.h, lo-ieee.h, lo-macros.h, lo-math.h, lo-regexp.h,
lo-traits.h, lo-utils.h, oct-alloc.h, oct-base64.h, oct-binmap.h, oct-cmplx.h,
oct-glob.h, oct-inttypes.h, oct-locbuf.h, oct-mutex.h, oct-refcount.h,
oct-rl-edit.h, oct-rl-hist.h, oct-shlib.h, oct-sort.h, oct-sparse.h,
pathsearch.h, singleton-cleanup.h, sparse-sort.h, sparse-util.h, statdefs.h,
str-vec.h, sun-utils.h, unwind-prot.h, url-transfer.h:
Use Octave coding conventions for #if statements.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 03 Dec 2015 10:23:38 -0800 |
parents | b6f2909e7f94 |
children | e3b3bb522d62 |
rev | line source |
---|---|
4153 | 1 /* |
2 | |
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19082
diff
changeset
|
3 Copyright (C) 2002-2015 John W. Eaton |
4153 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
4153 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
4153 | 20 |
21 */ | |
22 | |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
20785
diff
changeset
|
23 #if ! defined (octave_quit_h) |
4153 | 24 #define octave_quit_h 1 |
25 | |
19082
96df707c7dad
Do not include system header files in extern "C" block (bug #43171)
Johannes Zarl <johannes.zarl@jku.at>
parents:
17744
diff
changeset
|
26 #include <stdio.h> |
96df707c7dad
Do not include system header files in extern "C" block (bug #43171)
Johannes Zarl <johannes.zarl@jku.at>
parents:
17744
diff
changeset
|
27 |
96df707c7dad
Do not include system header files in extern "C" block (bug #43171)
Johannes Zarl <johannes.zarl@jku.at>
parents:
17744
diff
changeset
|
28 #include <signal.h> |
96df707c7dad
Do not include system header files in extern "C" block (bug #43171)
Johannes Zarl <johannes.zarl@jku.at>
parents:
17744
diff
changeset
|
29 #include <setjmp.h> |
96df707c7dad
Do not include system header files in extern "C" block (bug #43171)
Johannes Zarl <johannes.zarl@jku.at>
parents:
17744
diff
changeset
|
30 |
4153 | 31 #ifdef __cplusplus |
4268 | 32 #include <new> |
20666
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
33 #include <string> |
4153 | 34 extern "C" { |
35 #endif | |
36 | |
5451 | 37 #if defined (__WIN32__) && ! defined (_POSIX_VERSION) |
38 | |
10346
65d5776379c3
Reduce the amount of stuff included by windows.h and avoid min/max being #define-d
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10142
diff
changeset
|
39 #define WIN32_LEAN_AND_MEAN |
5451 | 40 #include <windows.h> |
41 | |
6107 | 42 CRUFT_API extern void w32_sigint_init (void); /* setup */ |
43 CRUFT_API extern void w32_raise_final (void); /* tear down */ | |
44 CRUFT_API extern void w32_raise (int sig); /* raise signal in main thread */ | |
45 CRUFT_API extern int w32_in_main_thread (void); /* return true if in main thread */ | |
5451 | 46 |
47 #endif | |
48 | |
4180 | 49 #if defined (OCTAVE_HAVE_SIG_JUMP) |
50 | |
51 typedef sigjmp_buf octave_jmp_buf; | |
52 | |
53 #define octave_set_current_context sigsetjmp (current_context, 1) | |
54 | |
55 #else | |
56 | |
57 typedef jmp_buf octave_jmp_buf; | |
58 | |
59 #define octave_set_current_context setjmp (current_context) | |
60 | |
61 #endif | |
62 | |
6107 | 63 CRUFT_API extern octave_jmp_buf current_context; |
4153 | 64 |
6107 | 65 CRUFT_API extern void octave_save_current_context (void *); |
4153 | 66 |
6107 | 67 CRUFT_API extern void octave_restore_current_context (void *); |
4153 | 68 |
6107 | 69 CRUFT_API extern void octave_jump_to_enclosing_context (void) GCC_ATTR_NORETURN; |
4153 | 70 |
6107 | 71 CRUFT_API extern void octave_save_signal_mask (void); |
4153 | 72 |
6107 | 73 CRUFT_API extern void octave_restore_signal_mask (void); |
4153 | 74 |
75 #ifdef __cplusplus | |
76 class | |
7481
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
77 octave_execution_exception |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
78 { |
20666
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
79 public: |
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
80 |
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
81 octave_execution_exception (void) : m_stack_trace () { } |
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
82 |
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
83 octave_execution_exception (const octave_execution_exception& x) |
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
84 : m_stack_trace (x.m_stack_trace) { } |
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
85 |
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
86 octave_execution_exception& operator = (const octave_execution_exception& x) |
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
87 { |
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
88 if (&x != this) |
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
89 m_stack_trace = x.m_stack_trace; |
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
90 |
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
91 return *this; |
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
92 } |
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
93 |
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
94 ~octave_execution_exception (void) { } |
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
95 |
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
96 virtual void set_stack_trace (const std::string& st) |
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
97 { |
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
98 m_stack_trace = st; |
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
99 } |
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
100 |
20785
b6f2909e7f94
always throw exception after debugging with debug_on_error
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
101 virtual void set_stack_trace (void) |
b6f2909e7f94
always throw exception after debugging with debug_on_error
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
102 { |
b6f2909e7f94
always throw exception after debugging with debug_on_error
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
103 m_stack_trace = ""; |
b6f2909e7f94
always throw exception after debugging with debug_on_error
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
104 } |
b6f2909e7f94
always throw exception after debugging with debug_on_error
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
105 |
20666
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
106 virtual std::string info (void) const |
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
107 { |
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
108 return m_stack_trace; |
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
109 } |
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
110 |
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
111 private: |
20785
b6f2909e7f94
always throw exception after debugging with debug_on_error
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
112 |
20666
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
113 std::string m_stack_trace; |
7481
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
114 }; |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
115 |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
116 class |
4153 | 117 octave_interrupt_exception |
118 { | |
119 }; | |
120 #endif | |
121 | |
7481
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
122 enum octave_exception |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
123 { |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
124 octave_no_exception = 0, |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
125 octave_exec_exception = 1, |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
126 octave_alloc_exception = 2 |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
127 }; |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
128 |
6107 | 129 CRUFT_API extern sig_atomic_t octave_interrupt_immediately; |
4153 | 130 |
5133 | 131 /* |
132 > 0: interrupt pending | |
133 0: no interrupt pending | |
134 < 0: handling interrupt | |
135 */ | |
6107 | 136 CRUFT_API extern sig_atomic_t octave_interrupt_state; |
4180 | 137 |
7481
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
138 CRUFT_API extern sig_atomic_t octave_exception_state; |
4153 | 139 |
8837
c37081b9d5c9
add missing volatile declaration in quit.h
Jaroslav Hajek <highegg@gmail.com>
parents:
7481
diff
changeset
|
140 CRUFT_API extern volatile sig_atomic_t octave_signal_caught; |
5142 | 141 |
6107 | 142 CRUFT_API extern void octave_handle_signal (void); |
5142 | 143 |
6107 | 144 CRUFT_API extern void octave_throw_interrupt_exception (void) GCC_ATTR_NORETURN; |
4153 | 145 |
7481
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
146 CRUFT_API extern void octave_throw_execution_exception (void) GCC_ATTR_NORETURN; |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
147 |
6107 | 148 CRUFT_API extern void octave_throw_bad_alloc (void) GCC_ATTR_NORETURN; |
4180 | 149 |
8928
80f044c83de3
quit.h (octave_rethrow_exception): Don't tag with GCC_ATTR_NORETURN
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
150 CRUFT_API extern void octave_rethrow_exception (void); |
7481
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
151 |
10142
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
9933
diff
changeset
|
152 #ifdef __cplusplus |
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
9933
diff
changeset
|
153 inline void octave_quit (void) |
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
9933
diff
changeset
|
154 { |
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
9933
diff
changeset
|
155 if (octave_signal_caught) |
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
9933
diff
changeset
|
156 { |
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
9933
diff
changeset
|
157 octave_signal_caught = 0; |
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
9933
diff
changeset
|
158 octave_handle_signal (); |
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
9933
diff
changeset
|
159 } |
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
9933
diff
changeset
|
160 }; |
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
9933
diff
changeset
|
161 |
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
9933
diff
changeset
|
162 #define OCTAVE_QUIT octave_quit () |
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
9933
diff
changeset
|
163 |
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
9933
diff
changeset
|
164 #else |
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
9933
diff
changeset
|
165 |
4153 | 166 #define OCTAVE_QUIT \ |
167 do \ | |
168 { \ | |
5142 | 169 if (octave_signal_caught) \ |
4153 | 170 { \ |
5142 | 171 octave_signal_caught = 0; \ |
172 octave_handle_signal (); \ | |
4153 | 173 } \ |
174 } \ | |
175 while (0) | |
10142
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
9933
diff
changeset
|
176 #endif |
4153 | 177 |
4302 | 178 /* Normally, you just want to use |
179 | |
180 BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; | |
181 ... some code that calls a "foreign" function ... | |
182 END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; | |
183 | |
184 but sometimes it is useful to do something like | |
185 | |
186 BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE_1; | |
187 ... custom code here, normally ending in a call to | |
7481
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
188 octave_rethrow_exception ... |
4302 | 189 BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE_2; |
190 | |
191 so that you can perform extra clean up operations before throwing | |
192 the interrupt exception. */ | |
193 | |
4153 | 194 #define BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE \ |
4302 | 195 BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE_1; \ |
7481
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
196 octave_rethrow_exception (); \ |
4302 | 197 BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE_2 |
198 | |
199 #define BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE_1 \ | |
4153 | 200 do \ |
201 { \ | |
4182 | 202 octave_jmp_buf saved_context; \ |
4153 | 203 \ |
5760 | 204 octave_save_current_context (saved_context); \ |
4153 | 205 \ |
206 if (octave_set_current_context) \ | |
9930
1ddc25c3623a
libcruft/misc: untabify sources
John W. Eaton <jwe@octave.org>
parents:
8928
diff
changeset
|
207 { \ |
1ddc25c3623a
libcruft/misc: untabify sources
John W. Eaton <jwe@octave.org>
parents:
8928
diff
changeset
|
208 octave_restore_current_context (saved_context) |
4302 | 209 |
210 #define BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE_2 \ | |
9930
1ddc25c3623a
libcruft/misc: untabify sources
John W. Eaton <jwe@octave.org>
parents:
8928
diff
changeset
|
211 } \ |
4153 | 212 else \ |
9930
1ddc25c3623a
libcruft/misc: untabify sources
John W. Eaton <jwe@octave.org>
parents:
8928
diff
changeset
|
213 { \ |
1ddc25c3623a
libcruft/misc: untabify sources
John W. Eaton <jwe@octave.org>
parents:
8928
diff
changeset
|
214 octave_interrupt_immediately++ |
4153 | 215 |
216 #define END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE \ | |
9930
1ddc25c3623a
libcruft/misc: untabify sources
John W. Eaton <jwe@octave.org>
parents:
8928
diff
changeset
|
217 octave_interrupt_immediately--; \ |
5760 | 218 octave_restore_current_context (saved_context); \ |
4153 | 219 } \ |
220 } \ | |
221 while (0) | |
222 | |
4196 | 223 #ifdef __cplusplus |
224 | |
4180 | 225 #define BEGIN_INTERRUPT_WITH_EXCEPTIONS \ |
4182 | 226 sig_atomic_t saved_octave_interrupt_immediately = octave_interrupt_immediately; \ |
4180 | 227 \ |
4182 | 228 try \ |
4180 | 229 { \ |
4182 | 230 octave_interrupt_immediately = 0; |
4180 | 231 |
232 #define END_INTERRUPT_WITH_EXCEPTIONS \ | |
233 } \ | |
20535
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
234 catch (const octave_interrupt_exception&) \ |
4180 | 235 { \ |
4182 | 236 octave_interrupt_immediately = saved_octave_interrupt_immediately; \ |
4180 | 237 octave_jump_to_enclosing_context (); \ |
238 } \ | |
20535
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
239 catch (const octave_execution_exception&) \ |
7481
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
240 { \ |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
241 octave_interrupt_immediately = saved_octave_interrupt_immediately; \ |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
242 octave_exception_state = octave_exec_exception; \ |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
243 octave_jump_to_enclosing_context (); \ |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
244 } \ |
20535
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
245 catch (const std::bad_alloc&) \ |
4180 | 246 { \ |
4182 | 247 octave_interrupt_immediately = saved_octave_interrupt_immediately; \ |
7481
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
248 octave_exception_state = octave_alloc_exception; \ |
4180 | 249 octave_jump_to_enclosing_context (); \ |
250 } \ | |
251 \ | |
4182 | 252 octave_interrupt_immediately = saved_octave_interrupt_immediately |
4196 | 253 #endif |
4153 | 254 |
255 #ifdef __cplusplus | |
256 } | |
4560 | 257 |
4572 | 258 /* These should only be declared for C++ code, and should also be |
259 outside of any extern "C" block. */ | |
4560 | 260 |
6107 | 261 extern CRUFT_API void (*octave_signal_hook) (void); |
262 extern CRUFT_API void (*octave_interrupt_hook) (void); | |
263 extern CRUFT_API void (*octave_bad_alloc_hook) (void); | |
4560 | 264 |
4153 | 265 #endif |
266 | |
267 #endif |