2544
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
2544
|
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 |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
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 |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
|
23 #if !defined (octave_f77_fcn_h) |
|
24 #define octave_f77_fcn_h 1 |
|
25 |
|
26 #ifdef __cplusplus |
|
27 extern "C" { |
|
28 #endif |
|
29 |
4153
|
30 #include "quit.h" |
2544
|
31 |
4153
|
32 #include <stdio.h> |
|
33 |
|
34 /* Hack to stringize macro results. */ |
3887
|
35 #define xSTRINGIZE(x) #x |
|
36 #define STRINGIZE(x) xSTRINGIZE(x) |
2544
|
37 |
|
38 /* How to print an error for the F77_XFCN macro. */ |
|
39 |
|
40 #define F77_XFCN_ERROR(f, F) \ |
|
41 (*current_liboctave_error_handler) \ |
3887
|
42 ("exception encountered in Fortran subroutine %s", \ |
|
43 STRINGIZE (F77_FUNC (f, F))) |
2544
|
44 |
|
45 /* This can be used to call a Fortran subroutine that might call |
4153
|
46 XSTOPX. XSTOPX will call lonjmp with current_context. Once back |
|
47 here, we'll restore the previous context and return. We may also |
|
48 end up here if an interrupt is processed when the Fortran |
|
49 subroutine is called. In that case, we resotre the context and go |
|
50 to the top level. The error_state should be checked immediately |
|
51 after this macro is used. */ |
2544
|
52 |
|
53 #define F77_XFCN(f, F, args) \ |
|
54 do \ |
|
55 { \ |
4153
|
56 jmp_buf saved_context; \ |
2544
|
57 f77_exception_encountered = 0; \ |
4153
|
58 octave_save_current_context ((char *) saved_context); \ |
|
59 if (octave_set_current_context) \ |
2544
|
60 { \ |
4153
|
61 octave_restore_current_context ((char *) saved_context); \ |
|
62 if (f77_exception_encountered) \ |
|
63 F77_XFCN_ERROR (f, F); \ |
|
64 else \ |
|
65 OCTAVE_THROW_TO_TOP_LEVEL; \ |
2544
|
66 } \ |
|
67 else \ |
4153
|
68 { \ |
|
69 octave_interrupt_immediately++; \ |
|
70 F77_FUNC (f, F) args; \ |
|
71 octave_interrupt_immediately--; \ |
|
72 octave_restore_current_context ((char *) saved_context); \ |
|
73 } \ |
2544
|
74 } \ |
|
75 while (0) |
|
76 |
|
77 /* So we can check to see if an exception has occurred. */ |
|
78 extern int f77_exception_encountered; |
|
79 |
3950
|
80 extern void |
|
81 F77_FUNC (xstopx, XSTOPX) (const char *s, long int slen) GCC_ATTR_NORETURN; |
|
82 |
3938
|
83 #if !defined (F77_FCN) |
|
84 #define F77_FCN(f, F) F77_FUNC (f, F) |
|
85 #endif |
|
86 |
2544
|
87 #ifdef __cplusplus |
|
88 } |
|
89 #endif |
|
90 |
|
91 #endif |
|
92 |
|
93 /* |
|
94 ;;; Local Variables: *** |
|
95 ;;; mode: C++ *** |
|
96 ;;; End: *** |
|
97 */ |