+ * debuglocus.c (create_duplicate_debuglocus): Allow non debuglocus
[official-gcc.git] / libgfortran / intrinsics / f2c_specifics.F90
blob85b539e291213c33428cb1e510b29fd71a58db27
1 !   Copyright 2002, 2005 Free Software Foundation, Inc.
2 !   Contributed by Tobias Schl"uter
4 !This file is part of the GNU Fortran 95 runtime library (libgfortran).
6 !GNU libgfortran is free software; you can redistribute it and/or
7 !modify it under the terms of the GNU General Public
8 !License as published by the Free Software Foundation; either
9 !version 2 of the License, or (at your option) any later version.
11 !In addition to the permissions in the GNU General Public License, the
12 !Free Software Foundation gives you unlimited permission to link the
13 !compiled version of this file into combinations with other programs,
14 !and to distribute those combinations without any restriction coming
15 !from the use of this file.  (The General Public License restrictions
16 !do apply in other respects; for example, they cover modification of
17 !the file, and distribution when not linked into a combine
18 !executable.)
20 !GNU libgfortran is distributed in the hope that it will be useful,
21 !but WITHOUT ANY WARRANTY; without even the implied warranty of
22 !MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23 !GNU General Public License for more details.
25 !You should have received a copy of the GNU General Public
26 !License along with libgfortran; see the file COPYING.  If not,
27 !write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
28 !Boston, MA 02110-1301, USA.
30 ! Specifics for the intrinsics whose calling conventions change if
31 ! -ff2c is used.
33 ! There are two annoyances WRT the preprocessor:
34 !  - we're using -traditional-cpp, so we can't use the ## operator.
35 !  - macros expand to a single line, and Fortran lines can't be wider
36 !    than 132 characters, therefore we use two macros to split the lines
38 ! The cases we need to implement are functions returning default REAL
39 ! or COMPLEX.  The former need to return DOUBLE PRECISION instead of REAL,
40 ! the latter become subroutines returning via a hidden first argument.
42 ! one argument functions
43 #define REAL_HEAD(NAME) \
44 elemental function _gfortran_f2c_specific__/**/NAME/**/_r4 (parm) result(res);
46 #define REAL_BODY(NAME) \
47   REAL, intent (in) :: parm; \
48   DOUBLE PRECISION :: res; \
49   res = NAME (parm); \
50 end function
52 #define COMPLEX_HEAD(NAME) \
53 subroutine _gfortran_f2c_specific__/**/NAME/**/_c4 (res, parm);
55 #define COMPLEX_BODY(NAME) \
56   COMPLEX, intent (in) :: parm; \
57   COMPLEX, intent (out) :: res; \
58   res = NAME (parm); \
59 end subroutine
61 #define DCOMPLEX_HEAD(NAME) \
62 subroutine _gfortran_f2c_specific__/**/NAME/**/_c8 (res, parm);
64 #define DCOMPLEX_BODY(NAME) \
65   DOUBLE COMPLEX, intent (in) :: parm; \
66   DOUBLE COMPLEX, intent (out) :: res; \
67   res = NAME (parm); \
68 end subroutine
70 REAL_HEAD(abs)
71 REAL_BODY(abs)
73 ! abs is special in that the result is real
74 elemental function _gfortran_f2c_specific__abs_c4 (parm) result (res)
75   COMPLEX, intent(in) :: parm
76   DOUBLE PRECISION :: res
77   res = abs(parm)
78 end function
81 ! aimag is special in that the result is real
82 elemental function _gfortran_f2c_specific__aimag_c4 (parm)
83   complex(kind=4), intent(in) :: parm
84   double precision :: _gfortran_f2c_specific__aimag_c4
85   _gfortran_f2c_specific__aimag_c4 = aimag(parm)
86 end function
88 elemental function _gfortran_f2c_specific__aimag_c8 (parm)
89   complex(kind=8), intent(in) :: parm
90   double precision :: _gfortran_f2c_specific__aimag_c8
91   _gfortran_f2c_specific__aimag_c8 = aimag(parm)
92 end function
95 REAL_HEAD(exp)
96 REAL_BODY(exp)
97 COMPLEX_HEAD(exp)
98 COMPLEX_BODY(exp)
99 DCOMPLEX_HEAD(exp)
100 DCOMPLEX_BODY(exp)
102 REAL_HEAD(log)
103 REAL_BODY(log)
104 COMPLEX_HEAD(log)
105 COMPLEX_BODY(log)
106 DCOMPLEX_HEAD(log)
107 DCOMPLEX_BODY(log)
109 REAL_HEAD(log10)
110 REAL_BODY(log10)
112 REAL_HEAD(sqrt)
113 REAL_BODY(sqrt)
114 COMPLEX_HEAD(sqrt)
115 COMPLEX_BODY(sqrt)
116 DCOMPLEX_HEAD(sqrt)
117 DCOMPLEX_BODY(sqrt)
119 REAL_HEAD(asin)
120 REAL_BODY(asin)
122 REAL_HEAD(acos)
123 REAL_BODY(acos)
125 REAL_HEAD(atan)
126 REAL_BODY(atan)
128 REAL_HEAD(asinh)
129 REAL_BODY(asinh)
131 REAL_HEAD(acosh)
132 REAL_BODY(acosh)
134 REAL_HEAD(atanh)
135 REAL_BODY(atanh)
137 REAL_HEAD(sin)
138 REAL_BODY(sin)
139 COMPLEX_HEAD(sin)
140 COMPLEX_BODY(sin)
141 DCOMPLEX_HEAD(sin)
142 DCOMPLEX_BODY(sin)
144 REAL_HEAD(cos)
145 REAL_BODY(cos)
146 COMPLEX_HEAD(cos)
147 COMPLEX_BODY(cos)
148 DCOMPLEX_HEAD(cos)
149 DCOMPLEX_BODY(cos)
151 REAL_HEAD(tan)
152 REAL_BODY(tan)
154 REAL_HEAD(sinh)
155 REAL_BODY(sinh)
157 REAL_HEAD(cosh)
158 REAL_BODY(cosh)
160 REAL_HEAD(tanh)
161 REAL_BODY(tanh)
163 REAL_HEAD(aint)
164 REAL_BODY(aint)
166 REAL_HEAD(anint)
167 REAL_BODY(anint)
169 ! two argument functions
170 #define REAL2_HEAD(NAME) \
171 elemental function _gfortran_f2c_specific__/**/NAME/**/_r4 (p1, p2) result(res);
173 #define REAL2_BODY(NAME) \
174   REAL, intent (in) :: p1, p2; \
175   DOUBLE PRECISION :: res; \
176   res = NAME (p1, p2); \
177 end function
179 REAL2_HEAD(sign)
180 REAL2_BODY(sign)
182 REAL2_HEAD(dim)
183 REAL2_BODY(dim)
185 REAL2_HEAD(atan2)
186 REAL2_BODY(atan2)
188 REAL2_HEAD(mod)
189 REAL2_BODY(mod)
191 ! conjg is special-cased because it is not suffixed _c4 but _4
192 subroutine _gfortran_f2c_specific__conjg_4 (res, parm)
193   COMPLEX, intent (in) :: parm
194   COMPLEX, intent (out) :: res
195   res = conjg (parm)
196 end subroutine
197 subroutine _gfortran_f2c_specific__conjg_8 (res, parm)
198   DOUBLE COMPLEX, intent (in) :: parm
199   DOUBLE COMPLEX, intent (out) :: res
200   res = conjg (parm)
201 end subroutine