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
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
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; \
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; \
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; \
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
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)
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)
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); \
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
197 subroutine _gfortran_f2c_specific__conjg_8 (res, parm)
198 DOUBLE COMPLEX, intent (in) :: parm
199 DOUBLE COMPLEX, intent (out) :: res