OSDN Git Service

Daily bump.
[pf3gnuchains/gcc-fork.git] / libgfortran / intrinsics / f2c_specifics.F90
1 !   Copyright 2002, 2005 Free Software Foundation, Inc.
2 !   Contributed by Tobias Schl"uter
3 !
4 !This file is part of the GNU Fortran 95 runtime library (libgfortran).
5 !
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.
10
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.)
19 !
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.
24 !
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.
29 !
30 ! Specifics for the intrinsics whose calling conventions change if
31 ! -ff2c is used.
32 !
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
37 !
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.
41
42 ! one argument functions
43 #define REAL_HEAD(NAME) \
44 elemental function _gfortran_f2c_specific__/**/NAME/**/_r4 (parm) result(res);
45
46 #define REAL_BODY(NAME) \
47   REAL, intent (in) :: parm; \
48   DOUBLE PRECISION :: res; \
49   res = NAME (parm); \
50 end function
51
52 #define COMPLEX_HEAD(NAME) \
53 subroutine _gfortran_f2c_specific__/**/NAME/**/_c4 (res, parm);
54
55 #define COMPLEX_BODY(NAME) \
56   COMPLEX, intent (in) :: parm; \
57   COMPLEX, intent (out) :: res; \
58   res = NAME (parm); \
59 end subroutine
60
61 #define DCOMPLEX_HEAD(NAME) \
62 subroutine _gfortran_f2c_specific__/**/NAME/**/_c8 (res, parm);
63
64 #define DCOMPLEX_BODY(NAME) \
65   DOUBLE COMPLEX, intent (in) :: parm; \
66   DOUBLE COMPLEX, intent (out) :: res; \
67   res = NAME (parm); \
68 end subroutine
69
70 REAL_HEAD(abs)
71 REAL_BODY(abs)
72
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
79
80
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
87
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
93
94
95 REAL_HEAD(exp)
96 REAL_BODY(exp)
97 COMPLEX_HEAD(exp)
98 COMPLEX_BODY(exp)
99 DCOMPLEX_HEAD(exp)
100 DCOMPLEX_BODY(exp)
101
102 REAL_HEAD(log)
103 REAL_BODY(log)
104 COMPLEX_HEAD(log)
105 COMPLEX_BODY(log)
106 DCOMPLEX_HEAD(log)
107 DCOMPLEX_BODY(log)
108
109 REAL_HEAD(log10)
110 REAL_BODY(log10)
111
112 REAL_HEAD(sqrt)
113 REAL_BODY(sqrt)
114 COMPLEX_HEAD(sqrt)
115 COMPLEX_BODY(sqrt)
116 DCOMPLEX_HEAD(sqrt)
117 DCOMPLEX_BODY(sqrt)
118
119 REAL_HEAD(asin)
120 REAL_BODY(asin)
121
122 REAL_HEAD(acos)
123 REAL_BODY(acos)
124
125 REAL_HEAD(atan)
126 REAL_BODY(atan)
127
128 REAL_HEAD(asinh)
129 REAL_BODY(asinh)
130
131 REAL_HEAD(acosh)
132 REAL_BODY(acosh)
133
134 REAL_HEAD(atanh)
135 REAL_BODY(atanh)
136
137 REAL_HEAD(sin)
138 REAL_BODY(sin)
139 COMPLEX_HEAD(sin)
140 COMPLEX_BODY(sin)
141 DCOMPLEX_HEAD(sin)
142 DCOMPLEX_BODY(sin)
143
144 REAL_HEAD(cos)
145 REAL_BODY(cos)
146 COMPLEX_HEAD(cos)
147 COMPLEX_BODY(cos)
148 DCOMPLEX_HEAD(cos)
149 DCOMPLEX_BODY(cos)
150
151 REAL_HEAD(tan)
152 REAL_BODY(tan)
153
154 REAL_HEAD(sinh)
155 REAL_BODY(sinh)
156
157 REAL_HEAD(cosh)
158 REAL_BODY(cosh)
159
160 REAL_HEAD(tanh)
161 REAL_BODY(tanh)
162
163 REAL_HEAD(aint)
164 REAL_BODY(aint)
165
166 REAL_HEAD(anint)
167 REAL_BODY(anint)
168
169 ! two argument functions
170 #define REAL2_HEAD(NAME) \
171 elemental function _gfortran_f2c_specific__/**/NAME/**/_r4 (p1, p2) result(res);
172
173 #define REAL2_BODY(NAME) \
174   REAL, intent (in) :: p1, p2; \
175   DOUBLE PRECISION :: res; \
176   res = NAME (p1, p2); \
177 end function
178
179 REAL2_HEAD(sign)
180 REAL2_BODY(sign)
181
182 REAL2_HEAD(dim)
183 REAL2_BODY(dim)
184
185 REAL2_HEAD(atan2)
186 REAL2_BODY(atan2)
187
188 REAL2_HEAD(mod)
189 REAL2_BODY(mod)
190
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
202