| 1 |
include(head.m4) |
| 2 |
define(atype_code,regexp(file,`_\([ircl][0-9]+\).[fF]90',`\1'))dnl |
| 3 |
define(atype_letter,substr(atype_code, 0, 1))dnl |
| 4 |
define(atype_kind,substr(atype_code, 1))dnl |
| 5 |
define(get_typename2, `$1 (kind=$2)')dnl |
| 6 |
define(get_typename, `get_typename2(ifelse($1,i,integer,ifelse($1,r,real,ifelse($1,l,logical,ifelse($1,c,complex,unknown)))),`$2')')dnl |
| 7 |
dnl |
| 8 |
dnl KIND=17 is special: This is just a naming convention |
| 9 |
dnl in the library, for Fortran source code KIND=16 is needed |
| 10 |
dnl |
| 11 |
define(name_kind, ifelse(atype_kind,17,16,atype_kind))dnl |
| 12 |
define(atype_name, get_typename(atype_letter,name_kind))dnl |
| 13 |
define(name, regexp(regexp(file, `[^/]*$', `\&'), `^_\([^_]*\)_', `\1'))dnl |
| 14 |
define(rtype_name,get_typename(ifelse(name,abs,ifelse(atype_letter,c,r,atype_letter),ifelse(name,aimag,ifelse(atype_letter,c,r,atype_letter),atype_letter)),name_kind))dnl |
| 15 |
define(function_name,dnl |
| 16 |
ifelse(name,conjg,`_gfortran_specific__conjg_'atype_kind,`_gfortran_specific__'name`_'atype_code))dnl |
| 17 |
|
| 18 |
define(type,dnl |
| 19 |
ifelse(atype_letter,l,LOGICAL,dnl |
| 20 |
ifelse(atype_letter,i,INTEGER,dnl |
| 21 |
ifelse(atype_letter,r,REAL,dnl |
| 22 |
ifelse(atype_letter,c,COMPLEX,UNKNOW)))))dnl |
| 23 |
define(Q,ifelse(atype_kind,4,F, |
| 24 |
ifelse(atype_kind,8,`', |
| 25 |
ifelse(atype_kind,10,L, |
| 26 |
ifelse(atype_kind,16,L, |
| 27 |
ifelse(atype_kind,17,L, |
| 28 |
`_'atype_kind))))))dnl |
| 29 |
|
| 30 |
dnl A few specifics require a function other than their name, or |
| 31 |
dnl nothing. The list is currently: |
| 32 |
dnl - integer and logical specifics require no libm function |
| 33 |
dnl - AINT requires the trunc() family functions |
| 34 |
dnl - ANINT requires round() |
| 35 |
dnl - AIMAG, CONJG, DIM, SIGN require no libm function |
| 36 |
define(needed,dnl |
| 37 |
ifelse(atype_letter,i,`none',dnl |
| 38 |
ifelse(atype_letter,l,`none',dnl |
| 39 |
ifelse(name,aint,trunc,dnl |
| 40 |
ifelse(name,anint,round,dnl |
| 41 |
ifelse(name,aimag,none,dnl |
| 42 |
ifelse(name,conjg,none,dnl |
| 43 |
ifelse(name,dim,none,dnl |
| 44 |
ifelse(name,sign,none,dnl |
| 45 |
ifelse(name,abs,fabs,name))))))))))dnl |
| 46 |
define(prefix,ifelse(atype_letter,c,C,`'))dnl |
| 47 |
|
| 48 |
dnl Special case for fabs, for which the corresponding complex function |
| 49 |
dnl is not cfabs but cabs. |
| 50 |
define(NEEDED,translit(ifelse(prefix`'needed,`Cfabs',`abs',needed),`a-z',`A-Z'))dnl |
| 51 |
|
| 52 |
#include "config.h" |
| 53 |
#include "kinds.inc" |
| 54 |
#include "c99_protos.inc" |
| 55 |
|
| 56 |
`#if defined (HAVE_GFC_'type`_'atype_kind`)' |
| 57 |
ifelse(NEEDED,NONE,`',`#ifdef HAVE_'prefix`'NEEDED`'Q) |
| 58 |
|
| 59 |
elemental function function_name (parm) |
| 60 |
atype_name, intent (in) :: parm |
| 61 |
rtype_name :: function_name |
| 62 |
|
| 63 |
function_name = name (parm) |
| 64 |
end function |
| 65 |
|
| 66 |
ifelse(NEEDED,NONE,`',`#endif') |
| 67 |
#endif |