* ChangeLog: Add missing entries to last entry.
[official-gcc.git] / libgfortran / intrinsics / f2c_specifics.F90
blob6fdcfe9776c446313a07b933d340c0704f2c070d
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 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 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 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)
72 ! abs is special in that the result is real
73 elemental function f2c_specific__abs_c4 (parm) result (res)
74   COMPLEX, intent(in) :: parm
75   DOUBLE PRECISION :: res
76   res = abs(parm)
77 end function
79 REAL_HEAD(exp)
80 REAL_BODY(exp)
81 COMPLEX_HEAD(exp)
82 COMPLEX_BODY(exp)
83 DCOMPLEX_HEAD(exp)
84 DCOMPLEX_BODY(exp)
86 REAL_HEAD(log)
87 REAL_BODY(log)
88 COMPLEX_HEAD(log)
89 COMPLEX_BODY(log)
90 DCOMPLEX_HEAD(log)
91 DCOMPLEX_BODY(log)
93 REAL_HEAD(log10)
94 REAL_BODY(log10)
96 REAL_HEAD(sqrt)
97 REAL_BODY(sqrt)
98 COMPLEX_HEAD(sqrt)
99 COMPLEX_BODY(sqrt)
100 DCOMPLEX_HEAD(sqrt)
101 DCOMPLEX_BODY(sqrt)
103 REAL_HEAD(asin)
104 REAL_BODY(asin)
106 REAL_HEAD(acos)
107 REAL_BODY(acos)
109 REAL_HEAD(atan)
110 REAL_BODY(atan)
112 REAL_HEAD(sin)
113 REAL_BODY(sin)
114 COMPLEX_HEAD(sin)
115 COMPLEX_BODY(sin)
116 DCOMPLEX_HEAD(sin)
117 DCOMPLEX_BODY(sin)
119 REAL_HEAD(cos)
120 REAL_BODY(cos)
121 COMPLEX_HEAD(cos)
122 COMPLEX_BODY(cos)
123 DCOMPLEX_HEAD(cos)
124 DCOMPLEX_BODY(cos)
126 REAL_HEAD(tan)
127 REAL_BODY(tan)
129 REAL_HEAD(sinh)
130 REAL_BODY(sinh)
132 REAL_HEAD(cosh)
133 REAL_BODY(cosh)
135 REAL_HEAD(tanh)
136 REAL_BODY(tanh)
138 REAL_HEAD(aint)
139 REAL_BODY(aint)
141 REAL_HEAD(anint)
142 REAL_BODY(anint)
144 ! two argument functions
145 #define REAL2_HEAD(NAME) \
146 elemental function f2c_specific__/**/NAME/**/_r4 (p1, p2) result(res);
148 #define REAL2_BODY(NAME) \
149   REAL, intent (in) :: p1, p2; \
150   DOUBLE PRECISION :: res; \
151   res = NAME (p1, p2); \
152 end function
154 REAL2_HEAD(sign)
155 REAL2_BODY(sign)
157 REAL2_HEAD(dim)
158 REAL2_BODY(dim)
160 REAL2_HEAD(atan2)
161 REAL2_BODY(atan2)
163 REAL2_HEAD(mod)
164 REAL2_BODY(mod)
166 ! conjg is special-cased because it is not suffixed _c4 but _4
167 subroutine f2c_specific__conjg_4 (res, parm)
168   COMPLEX, intent (in) :: parm
169   COMPLEX, intent (out) :: res
170   res = conjg (parm)
171 end subroutine
172 subroutine f2c_specific__conjg_8 (res, parm)
173   DOUBLE COMPLEX, intent (in) :: parm
174   DOUBLE COMPLEX, intent (out) :: res
175   res = conjg (parm)
176 end subroutine