summaryrefslogtreecommitdiffstats
path: root/libgfortran/m4/misc_specifics.m4
blob: 3e40bf01784a17a0175c5eb734e9820aadb242a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
include(head.m4)dnl
dnl
dnl This file contains the specific functions that are not handled in the
dnl m4/specific.m4 file.

#include "config.h"
#include "kinds.inc"

dnl This is from GNU m4 examples file foreach.m4:
divert(-1)
# foreach(x, (item_1, item_2, ..., item_n), stmt)
define(`foreach', `pushdef(`$1', `')_foreach(`$1', `$2',
`$3')popdef(`$1')')
define(`_arg1', `$1')
define(`_foreach',
        `ifelse(`$2', `()', ,
                `define(`$1', _arg1$2)$3`'_foreach(`$1', (shift$2),
`$3')')')
# traceon(`define', `foreach', `_foreach', `ifelse')
divert

dnl   NINT specifics
foreach(`ikind', `(4, 8, 16)', `foreach(`rkind', `(4, 8, 10, 16)', `
`#if defined (HAVE_GFC_REAL_'rkind`) && defined (HAVE_GFC_INTEGER_'ikind`)'
elemental function _gfortran_specific__nint_`'ikind`_'rkind (parm)
   real (kind=rkind) , intent (in) :: parm
   integer (kind=ikind) :: _gfortran_specific__nint_`'ikind`_'rkind
   _gfortran_specific__nint_`'ikind`_'rkind = nint (parm)
end function
#endif
')')

dnl   CHAR specifics
foreach(`ckind', `(1)', `foreach(`ikind', `(4, 8, 16)', `
`#if defined (HAVE_GFC_INTEGER_'ikind`)'
elemental function _gfortran_specific__char_`'ckind`_i'ikind (parm)
   integer (kind=ikind) , intent (in) :: parm
   character (kind=ckind,len=1) :: _gfortran_specific__char_`'ckind`_i'ikind
   _gfortran_specific__char_`'ckind`_i'ikind` = char (parm, kind='ckind`)'
end function
#endif
')')

dnl   LEN specifics
foreach(`ckind', `(1)', `foreach(`ikind', `(4, 8, 16)', `
`#if defined (HAVE_GFC_INTEGER_'ikind`)'
elemental function _gfortran_specific__len_`'ckind`_i'ikind (parm)
   character (kind=ckind,len=*) , intent (in) :: parm
   integer (kind=ikind) :: _gfortran_specific__len_`'ckind`_i'ikind
   _gfortran_specific__len_`'ckind`_i'ikind` = len (parm)'
end function
#endif
')')

dnl   INDEX specifics
foreach(`ckind', `(1)', `foreach(`ikind', `(4, 8, 16)', `
`#if defined (HAVE_GFC_INTEGER_'ikind`)'
elemental function _gfortran_specific__index_`'ckind`_i'ikind (parm1, parm2)
   character (kind=ckind,len=*) , intent (in) :: parm1, parm2
   integer (kind=ikind) :: _gfortran_specific__index_`'ckind`_i'ikind
   _gfortran_specific__index_`'ckind`_i'ikind` = index (parm1, parm2)'
end function
#endif
')')
OpenPOWER on IntegriCloud