Mercurial > octave
annotate liboctave/cruft/misc/f77-fcn.h @ 21229:a83e7a384ee0
create and install a subset of config.h in octave-config.h
* mk-octave-config-h.sh: New file.
* Makefile.am (EXTRA_DIST): Add mk-octave-config.h.sh to the list.
(octinclude_HEADERS): Add octave-config.h to the list.
(octave-config.h): New rule.
* common.mk (do_subst_config_vals, do_subst_cross_config_vals):
Don't substitute unused ENABLE options.
* configure.ac: Note the reason for using oct-conf-post.in.h.
Add OCTAVE_ prefix to ENABLE_BOUNDS_CHECK ENABLE_ATOMIC_REFCOUNT,
ENABLE_64, ENABLE_OPENMP, and ENABLE_FLOAT_TRUNCATE in calls to
AC_DEFINE. Change all uses.
* oct-conf-post.in.h: Define HAVE_OCTAVE_DEPRECATED_ATTR instead of
HAVE_ATTR_DEPRECATED. Likewise for HAVE_ATTR_NORETURN and
HAVE_ATTR_UNUSED. Change all uses.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 08 Feb 2016 17:30:29 -0500 |
parents | 25150962bfd3 |
children | 1473547f50f5 |
rev | line source |
---|---|
2544 | 1 /* |
2 | |
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
3 Copyright (C) 1996-2015 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 | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
2544 | 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/>. | |
2544 | 20 |
21 */ | |
22 | |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
20545
diff
changeset
|
23 #if ! defined (octave_f77_fcn_h) |
2544 | 24 #define octave_f77_fcn_h 1 |
25 | |
4268 | 26 #include "quit.h" |
27 | |
2544 | 28 #ifdef __cplusplus |
29 extern "C" { | |
30 #endif | |
31 | |
4153 | 32 /* Hack to stringize macro results. */ |
3887 | 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 | |
4153 | 44 XSTOPX. XSTOPX will call lonjmp with current_context. Once back |
45 here, we'll restore the previous context and return. We may also | |
46 end up here if an interrupt is processed when the Fortran | |
47 subroutine is called. In that case, we resotre the context and go | |
20545
c547458dc10e
eliminate error_state from most header files
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
48 to the top level. */ |
2544 | 49 |
50 #define F77_XFCN(f, F, args) \ | |
51 do \ | |
52 { \ | |
4182 | 53 octave_jmp_buf saved_context; \ |
5767 | 54 sig_atomic_t saved_octave_interrupt_immediately = octave_interrupt_immediately; \ |
2544 | 55 f77_exception_encountered = 0; \ |
5760 | 56 octave_save_current_context (saved_context); \ |
4153 | 57 if (octave_set_current_context) \ |
9930
1ddc25c3623a
libcruft/misc: untabify sources
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
58 { \ |
1ddc25c3623a
libcruft/misc: untabify sources
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
59 octave_interrupt_immediately = saved_octave_interrupt_immediately; \ |
5760 | 60 octave_restore_current_context (saved_context); \ |
9930
1ddc25c3623a
libcruft/misc: untabify sources
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
61 if (f77_exception_encountered) \ |
1ddc25c3623a
libcruft/misc: untabify sources
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
62 F77_XFCN_ERROR (f, F); \ |
4153 | 63 else \ |
9930
1ddc25c3623a
libcruft/misc: untabify sources
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
64 octave_rethrow_exception (); \ |
1ddc25c3623a
libcruft/misc: untabify sources
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
65 } \ |
2544 | 66 else \ |
4153 | 67 { \ |
9930
1ddc25c3623a
libcruft/misc: untabify sources
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
68 octave_interrupt_immediately++; \ |
1ddc25c3623a
libcruft/misc: untabify sources
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
69 F77_FUNC (f, F) args; \ |
1ddc25c3623a
libcruft/misc: untabify sources
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
70 octave_interrupt_immediately--; \ |
5760 | 71 octave_restore_current_context (saved_context); \ |
4153 | 72 } \ |
2544 | 73 } \ |
74 while (0) | |
75 | |
76 /* So we can check to see if an exception has occurred. */ | |
21227 | 77 OCTAVE_API extern int f77_exception_encountered; |
2544 | 78 |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
20545
diff
changeset
|
79 #if ! defined (F77_FCN) |
3938 | 80 #define F77_FCN(f, F) F77_FUNC (f, F) |
81 #endif | |
82 | |
15128
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
83 /* |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
84 |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
85 The following macros are used for handling Fortran <-> C calling |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
86 conventions. They are defined below for three different types of |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
87 systems, Cray (possibly now obsolete), Visual Fortran, and any system |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
88 that is compatible with the f2c calling conventions, including g77 and |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
89 gfortran. Note that gfortran is not completely compatible with the |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
90 f2c calling conventions, but that we only use the parts that are |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
91 compatible. For example, f2c and gfortran differ in the way they |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
92 handle Fortran functions that return complex values, but Octave does |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
93 not call any Fortran functions like that directly from C or C++. |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
94 |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
95 Use these macros to pass character strings from C to Fortran: |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
96 |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
97 F77_CHAR_ARG(x) |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
98 F77_CONST_CHAR_ARG(x) |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
99 F77_CXX_STRING_ARG(x) |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
100 F77_CHAR_ARG_LEN(l) |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
101 F77_CHAR_ARG_DECL |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
102 F77_CONST_CHAR_ARG_DECL |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
103 F77_CHAR_ARG_LEN_DECL |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
104 |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
105 Use these macros to write C-language functions that accept |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
106 Fortran-style character strings: |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
107 |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
108 F77_CHAR_ARG_DEF(s, len) |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
109 F77_CONST_CHAR_ARG_DEF(s, len) |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
110 F77_CHAR_ARG_LEN_DEF(len) |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
111 F77_CHAR_ARG_USE(s) |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
112 F77_CHAR_ARG_LEN_USE(s, len) |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
113 |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
114 Use this macro to declare the return type of a C-language function |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
115 that is supposed to act like a Fortran subroutine: |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
116 |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
117 F77_RET_T int |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
118 |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
119 Use these macros to return from C-language functions that are supposed |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
120 to act like Fortran subroutines. F77_NORETURN is intended to be used |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
121 as the last statement of such a function that has been tagged with a |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
122 "noreturn" attribute. If the compiler supports the "noreturn" |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
123 attribute or if F77_RET_T is void, then it should expand to nothing so |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
124 that we avoid warnings about functions tagged as "noreturn" |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
125 containing a return statement. Otherwise, it should expand to a |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
126 statement that returns the given value so that we avoid warnings about |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
127 not returning a value from a function declared to return something. |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
128 |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
129 F77_RETURN(retval) |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
130 F77_NORETURN(retval) |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
131 |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
132 */ |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
133 |
4552 | 134 #if defined (F77_USES_CRAY_CALLING_CONVENTION) |
135 | |
136 #include <fortran.h> | |
6072 | 137 |
138 /* Use these macros to pass character strings from C to Fortran. */ | |
4552 | 139 #define F77_CHAR_ARG(x) octave_make_cray_ftn_ch_dsc (x, strlen (x)) |
140 #define F77_CONST_CHAR_ARG(x) \ | |
141 octave_make_cray_const_ftn_ch_dsc (x, strlen (x)) | |
4577 | 142 #define F77_CHAR_ARG2(x, l) octave_make_cray_ftn_ch_dsc (x, l) |
143 #define F77_CONST_CHAR_ARG2(x, l) octave_make_cray_const_ftn_ch_dsc (x, l) | |
4552 | 144 #define F77_CXX_STRING_ARG(x) \ |
145 octave_make_cray_const_ftn_ch_dsc (x.c_str (), x.length ()) | |
146 #define F77_CHAR_ARG_LEN(l) | |
4577 | 147 #define F77_CHAR_ARG_DECL octave_cray_ftn_ch_dsc |
148 #define F77_CONST_CHAR_ARG_DECL octave_cray_ftn_ch_dsc | |
4552 | 149 #define F77_CHAR_ARG_LEN_DECL |
6072 | 150 |
151 /* Use these macros to write C-language functions that accept | |
152 Fortran-style character strings. */ | |
153 #define F77_CHAR_ARG_DEF(s, len) octave_cray_ftn_ch_dsc s | |
154 #define F77_CONST_CHAR_ARG_DEF(s, len) octave_cray_ftn_ch_dsc s | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
155 #define F77_CHAR_ARG_LEN_DEF(len) |
6072 | 156 #define F77_CHAR_ARG_USE(s) s.ptr |
157 #define F77_CHAR_ARG_LEN_USE(s, len) (s.mask.len>>3) | |
158 | |
15128
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
159 /* Use this macro to declare the return type of a C-language function |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
160 that is supposed to act like a Fortran subroutine. */ |
4552 | 161 #define F77_RET_T int |
15128
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
162 |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
163 /* Use these macros to return from C-language functions that are |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
164 supposed to act like Fortran subroutines. F77_NORETURN is intended |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
165 to be used as the last statement of such a function that has been |
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
166 tagged with a "noreturn" attribute. */ |
4552 | 167 #define F77_RETURN(retval) return retval; |
21229
a83e7a384ee0
create and install a subset of config.h in octave-config.h
John W. Eaton <jwe@octave.org>
parents:
21227
diff
changeset
|
168 #if defined (HAVE_OCTAVE_NORETURN_ATTR) |
21202
f7121e111991
maint: indent #ifdef blocks in liboctave and src directories.
Rik <rik@octave.org>
parents:
21076
diff
changeset
|
169 # define F77_NORETURN(retval) |
15127
87411930d6c4
avoid "function declared 'noreturn' has a return statement" warning.
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
170 #else |
21202
f7121e111991
maint: indent #ifdef blocks in liboctave and src directories.
Rik <rik@octave.org>
parents:
21076
diff
changeset
|
171 # define F77_NORETURN(retval) return retval; |
15127
87411930d6c4
avoid "function declared 'noreturn' has a return statement" warning.
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
172 #endif |
4552 | 173 |
21066
258c787cd9ce
maint: Use "FIXME:" consistently in code base.
Rik <rik@octave.org>
parents:
21040
diff
changeset
|
174 /* FIXME: These should work for SV1 or Y-MP systems but will |
258c787cd9ce
maint: Use "FIXME:" consistently in code base.
Rik <rik@octave.org>
parents:
21040
diff
changeset
|
175 need to be changed for others. */ |
4552 | 176 |
4558 | 177 typedef union |
4552 | 178 { |
4558 | 179 const char *const_ptr; |
180 char *ptr; | |
4552 | 181 struct |
182 { | |
183 unsigned off : 6; | |
184 unsigned len : 26; | |
185 unsigned add : 32; | |
186 } mask; | |
4558 | 187 } octave_cray_descriptor; |
4552 | 188 |
189 typedef void *octave_cray_ftn_ch_dsc; | |
190 | |
4555 | 191 #ifdef __cplusplus |
21202
f7121e111991
maint: indent #ifdef blocks in liboctave and src directories.
Rik <rik@octave.org>
parents:
21076
diff
changeset
|
192 # define OCTAVE_F77_FCN_INLINE inline |
4558 | 193 #else |
21202
f7121e111991
maint: indent #ifdef blocks in liboctave and src directories.
Rik <rik@octave.org>
parents:
21076
diff
changeset
|
194 # define OCTAVE_F77_FCN_INLINE |
4555 | 195 #endif |
196 | |
197 static OCTAVE_F77_FCN_INLINE octave_cray_ftn_ch_dsc | |
4552 | 198 octave_make_cray_ftn_ch_dsc (char *ptr_arg, unsigned long len_arg) |
199 { | |
200 octave_cray_descriptor desc; | |
201 desc.ptr = ptr_arg; | |
202 desc.mask.len = len_arg << 3; | |
4558 | 203 return *((octave_cray_ftn_ch_dsc *) &desc); |
4552 | 204 } |
205 | |
4555 | 206 static OCTAVE_F77_FCN_INLINE octave_cray_ftn_ch_dsc |
4552 | 207 octave_make_cray_const_ftn_ch_dsc (const char *ptr_arg, unsigned long len_arg) |
208 { | |
209 octave_cray_descriptor desc; | |
210 desc.const_ptr = ptr_arg; | |
211 desc.mask.len = len_arg << 3; | |
4558 | 212 return *((octave_cray_ftn_ch_dsc *) &desc); |
4552 | 213 } |
214 | |
4555 | 215 #ifdef __cplusplus |
21202
f7121e111991
maint: indent #ifdef blocks in liboctave and src directories.
Rik <rik@octave.org>
parents:
21076
diff
changeset
|
216 # undef OCTAVE_F77_FCN_INLINE |
4555 | 217 #endif |
218 | |
4552 | 219 #elif defined (F77_USES_VISUAL_FORTRAN_CALLING_CONVENTION) |
220 | |
6072 | 221 /* Use these macros to pass character strings from C to Fortran. */ |
4552 | 222 #define F77_CHAR_ARG(x) x, strlen (x) |
223 #define F77_CONST_CHAR_ARG(x) F77_CHAR_ARG (x) | |
224 #define F77_CHAR_ARG2(x, l) x, l | |
225 #define F77_CONST_CHAR_ARG2(x, l) F77_CHAR_ARG2 (x, l) | |
226 #define F77_CXX_STRING_ARG(x) F77_CONST_CHAR_ARG2 (x.c_str (), x.length ()) | |
227 #define F77_CHAR_ARG_LEN(l) | |
228 #define F77_CHAR_ARG_DECL char *, int | |
229 #define F77_CONST_CHAR_ARG_DECL const char *, int | |
230 #define F77_CHAR_ARG_LEN_DECL | |
6072 | 231 |
232 #define F77_CHAR_ARG_DEF(s, len) char *s, int len | |
233 #define F77_CONST_CHAR_ARG_DEF(s, len) const char *s, int len | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
234 #define F77_CHAR_ARG_LEN_DEF(len) |
6072 | 235 #define F77_CHAR_ARG_USE(s) s |
236 #define F77_CHAR_ARG_LEN_USE(s, len) len | |
237 | |
4552 | 238 #define F77_RET_T void |
15128
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
239 |
15127
87411930d6c4
avoid "function declared 'noreturn' has a return statement" warning.
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
240 #define F77_RETURN(retval) return; |
87411930d6c4
avoid "function declared 'noreturn' has a return statement" warning.
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
241 #define F77_NORETURN(retval) |
4552 | 242 |
243 #else | |
244 | |
4572 | 245 /* Assume f2c-compatible calling convention. */ |
4552 | 246 |
247 #define F77_CHAR_ARG(x) x | |
248 #define F77_CONST_CHAR_ARG(x) F77_CHAR_ARG (x) | |
249 #define F77_CHAR_ARG2(x, l) x | |
250 #define F77_CONST_CHAR_ARG2(x, l) F77_CHAR_ARG2 (x, l) | |
251 #define F77_CXX_STRING_ARG(x) F77_CONST_CHAR_ARG2 (x.c_str (), x.length ()) | |
5760 | 252 #define F77_CHAR_ARG_LEN(l) , l |
4552 | 253 #define F77_CHAR_ARG_DECL char * |
254 #define F77_CONST_CHAR_ARG_DECL const char * | |
255 #define F77_CHAR_ARG_LEN_DECL , long | |
6072 | 256 |
257 #define F77_CHAR_ARG_DEF(s, len) char *s | |
258 #define F77_CONST_CHAR_ARG_DEF(s, len) const char *s | |
259 #define F77_CHAR_ARG_LEN_DEF(len) , long len | |
260 #define F77_CHAR_ARG_USE(s) s | |
261 #define F77_CHAR_ARG_LEN_USE(s, len) len | |
262 | |
4552 | 263 #define F77_RET_T int |
15128
4d52239daef5
improve internal documentation of F77_ macros.
John W. Eaton <jwe@octave.org>
parents:
15127
diff
changeset
|
264 |
4552 | 265 #define F77_RETURN(retval) return retval; |
21229
a83e7a384ee0
create and install a subset of config.h in octave-config.h
John W. Eaton <jwe@octave.org>
parents:
21227
diff
changeset
|
266 #if defined (HAVE_OCTAVE_NORETURN_ATTR) |
21202
f7121e111991
maint: indent #ifdef blocks in liboctave and src directories.
Rik <rik@octave.org>
parents:
21076
diff
changeset
|
267 # define F77_NORETURN(retval) |
15127
87411930d6c4
avoid "function declared 'noreturn' has a return statement" warning.
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
268 #else |
21202
f7121e111991
maint: indent #ifdef blocks in liboctave and src directories.
Rik <rik@octave.org>
parents:
21076
diff
changeset
|
269 # define F77_NORETURN(retval) return retval; |
15127
87411930d6c4
avoid "function declared 'noreturn' has a return statement" warning.
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
270 #endif |
4552 | 271 |
272 #endif | |
273 | |
6072 | 274 |
275 /* Build a C string local variable CS from the Fortran string parameter S | |
276 declared as F77_CHAR_ARG_DEF(s, len) or F77_CONST_CHAR_ARG_DEF(s, len). | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
277 The string will be cleaned up at the end of the current block. |
6072 | 278 Needs to include <cstring> and <vector>. */ |
279 | |
280 #define F77_CSTRING(s, len, cs) \ | |
6253 | 281 OCTAVE_LOCAL_BUFFER (char, cs, F77_CHAR_ARG_LEN_USE (s, len) + 1); \ |
6072 | 282 memcpy (cs, F77_CHAR_ARG_USE (s), F77_CHAR_ARG_LEN_USE (s, len)); \ |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
283 cs[F77_CHAR_ARG_LEN_USE(s, len)] = '\0' |
6072 | 284 |
285 | |
21227 | 286 OCTAVE_NORETURN OCTAVE_API extern |
21076
b433f9990452
strip trailing whitespace from files
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
287 F77_RET_T |
4801 | 288 F77_FUNC (xstopx, XSTOPX) (F77_CONST_CHAR_ARG_DECL |
21029
e3b3bb522d62
maint: Move GCC_ attributes to start of declaration for future compatibility.
Rik <rik@octave.org>
parents:
20791
diff
changeset
|
289 F77_CHAR_ARG_LEN_DECL); |
4552 | 290 |
2544 | 291 #ifdef __cplusplus |
292 } | |
293 #endif | |
294 | |
295 #endif |