annotate libcruft/misc/f77-fcn.h @ 4153:6b96ce9f5743

[project @ 2002-11-06 20:38:49 by jwe]
author jwe
date Wed, 06 Nov 2002 20:38:50 +0000
parents 9be12c29c7d5
children 61fba034b13b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2544
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
1 /*
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
2
2847
8b262e771614 [project @ 1997-03-27 16:18:26 by jwe]
jwe
parents: 2544
diff changeset
3 Copyright (C) 1996, 1997 John W. Eaton
2544
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
4
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
6
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
10 later version.
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
11
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
15 for more details.
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
16
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, write to the Free
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
20
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
21 */
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
22
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
23 #if !defined (octave_f77_fcn_h)
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
24 #define octave_f77_fcn_h 1
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
25
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
26 #ifdef __cplusplus
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
27 extern "C" {
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
28 #endif
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
29
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3950
diff changeset
30 #include "quit.h"
2544
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
31
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3950
diff changeset
32 #include <stdio.h>
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3950
diff changeset
33
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3950
diff changeset
34 /* Hack to stringize macro results. */
3887
7da18459c08b [project @ 2002-04-04 00:44:21 by jwe]
jwe
parents: 2847
diff changeset
35 #define xSTRINGIZE(x) #x
7da18459c08b [project @ 2002-04-04 00:44:21 by jwe]
jwe
parents: 2847
diff changeset
36 #define STRINGIZE(x) xSTRINGIZE(x)
2544
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
37
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
38 /* How to print an error for the F77_XFCN macro. */
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
39
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
40 #define F77_XFCN_ERROR(f, F) \
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
41 (*current_liboctave_error_handler) \
3887
7da18459c08b [project @ 2002-04-04 00:44:21 by jwe]
jwe
parents: 2847
diff changeset
42 ("exception encountered in Fortran subroutine %s", \
7da18459c08b [project @ 2002-04-04 00:44:21 by jwe]
jwe
parents: 2847
diff changeset
43 STRINGIZE (F77_FUNC (f, F)))
2544
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
44
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
45 /* This can be used to call a Fortran subroutine that might call
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3950
diff changeset
46 XSTOPX. XSTOPX will call lonjmp with current_context. Once back
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3950
diff changeset
47 here, we'll restore the previous context and return. We may also
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3950
diff changeset
48 end up here if an interrupt is processed when the Fortran
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3950
diff changeset
49 subroutine is called. In that case, we resotre the context and go
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3950
diff changeset
50 to the top level. The error_state should be checked immediately
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3950
diff changeset
51 after this macro is used. */
2544
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
52
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
53 #define F77_XFCN(f, F, args) \
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
54 do \
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
55 { \
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3950
diff changeset
56 jmp_buf saved_context; \
2544
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
57 f77_exception_encountered = 0; \
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3950
diff changeset
58 octave_save_current_context ((char *) saved_context); \
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3950
diff changeset
59 if (octave_set_current_context) \
2544
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
60 { \
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3950
diff changeset
61 octave_restore_current_context ((char *) saved_context); \
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3950
diff changeset
62 if (f77_exception_encountered) \
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3950
diff changeset
63 F77_XFCN_ERROR (f, F); \
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3950
diff changeset
64 else \
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3950
diff changeset
65 OCTAVE_THROW_TO_TOP_LEVEL; \
2544
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
66 } \
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
67 else \
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3950
diff changeset
68 { \
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3950
diff changeset
69 octave_interrupt_immediately++; \
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3950
diff changeset
70 F77_FUNC (f, F) args; \
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3950
diff changeset
71 octave_interrupt_immediately--; \
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3950
diff changeset
72 octave_restore_current_context ((char *) saved_context); \
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3950
diff changeset
73 } \
2544
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
74 } \
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
75 while (0)
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
76
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
77 /* So we can check to see if an exception has occurred. */
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
78 extern int f77_exception_encountered;
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
79
3950
9be12c29c7d5 [project @ 2002-05-23 03:00:00 by jwe]
jwe
parents: 3938
diff changeset
80 extern void
9be12c29c7d5 [project @ 2002-05-23 03:00:00 by jwe]
jwe
parents: 3938
diff changeset
81 F77_FUNC (xstopx, XSTOPX) (const char *s, long int slen) GCC_ATTR_NORETURN;
9be12c29c7d5 [project @ 2002-05-23 03:00:00 by jwe]
jwe
parents: 3938
diff changeset
82
3938
028eb74026bc [project @ 2002-05-16 16:15:42 by jwe]
jwe
parents: 3887
diff changeset
83 #if !defined (F77_FCN)
028eb74026bc [project @ 2002-05-16 16:15:42 by jwe]
jwe
parents: 3887
diff changeset
84 #define F77_FCN(f, F) F77_FUNC (f, F)
028eb74026bc [project @ 2002-05-16 16:15:42 by jwe]
jwe
parents: 3887
diff changeset
85 #endif
028eb74026bc [project @ 2002-05-16 16:15:42 by jwe]
jwe
parents: 3887
diff changeset
86
2544
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
87 #ifdef __cplusplus
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
88 }
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
89 #endif
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
90
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
91 #endif
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
92
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
93 /*
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
94 ;;; Local Variables: ***
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
95 ;;; mode: C++ ***
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
96 ;;; End: ***
a33bbd3fadd7 [project @ 1996-11-20 05:09:29 by jwe]
jwe
parents:
diff changeset
97 */