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 |
|
30 #include <setjmp.h> |
|
31 |
3887
|
32 /* hack to stringize macro results */ |
|
33 #define xSTRINGIZE(x) #x |
|
34 #define STRINGIZE(x) xSTRINGIZE(x) |
2544
|
35 |
|
36 /* How to print an error for the F77_XFCN macro. */ |
|
37 |
|
38 #define F77_XFCN_ERROR(f, F) \ |
|
39 (*current_liboctave_error_handler) \ |
3887
|
40 ("exception encountered in Fortran subroutine %s", \ |
|
41 STRINGIZE (F77_FUNC (f, F))) |
2544
|
42 |
|
43 /* This can be used to call a Fortran subroutine that might call |
|
44 XSTOPX. XSTOPX will call lonjmp with f77_context and we'll return, |
|
45 call the error function, restore the previous context. After using |
|
46 this macro, error_state should be checked. */ |
|
47 |
|
48 #define F77_XFCN(f, F, args) \ |
|
49 do \ |
|
50 { \ |
|
51 jmp_buf saved_f77_context; \ |
|
52 f77_exception_encountered = 0; \ |
|
53 copy_f77_context ((char *) f77_context, (char *) saved_f77_context, \ |
|
54 sizeof (jmp_buf)); \ |
|
55 if (setjmp (f77_context)) \ |
|
56 { \ |
|
57 f77_exception_encountered = 1; \ |
|
58 F77_XFCN_ERROR (f, F); \ |
|
59 } \ |
|
60 else \ |
3887
|
61 F77_FUNC (f, F) args; \ |
2544
|
62 copy_f77_context ((char *) saved_f77_context, (char *) f77_context, \ |
|
63 sizeof (jmp_buf)); \ |
|
64 } \ |
|
65 while (0) |
|
66 |
|
67 /* So we can check to see if an exception has occurred. */ |
|
68 extern int f77_exception_encountered; |
|
69 |
|
70 /* For setjmp/longjmp. */ |
|
71 extern jmp_buf f77_context; |
|
72 |
|
73 /* Defining this as a separate function allows us to avoid having to |
|
74 include string.h in this file. */ |
|
75 |
|
76 extern void copy_f77_context (void *, void *, unsigned int); |
|
77 |
3938
|
78 #if !defined (F77_FCN) |
|
79 #define F77_FCN(f, F) F77_FUNC (f, F) |
|
80 #endif |
|
81 |
2544
|
82 #ifdef __cplusplus |
|
83 } |
|
84 #endif |
|
85 |
|
86 #endif |
|
87 |
|
88 /* |
|
89 ;;; Local Variables: *** |
|
90 ;;; mode: C++ *** |
|
91 ;;; End: *** |
|
92 */ |