Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Thomas Jahns
PPM
Commits
d73c5415
Commit
d73c5415
authored
Mar 02, 2021
by
Thomas Jahns
🤸
Browse files
Automatically generate correct cfortran.h prototypes in Ansi mode.
parent
22dac3d1
Changes
1
Hide whitespace changes
Inline
Side-by-side
include/cfortran.h
View file @
d73c5415
...
...
@@ -402,10 +402,12 @@ only C calling FORTRAN subroutines will work using K&R style.*/
#ifndef apolloFortran
#define COMMON_BLOCK_DEF(DEFINITION, NAME) extern DEFINITION NAME
#define CF_NULL_PROTO
#define CF_NULL_PROTO void
#define CF_VOID_PROTO void
#else
/* HP doesn't understand #elif. */
/* Without ANSI prototyping, Apollo promotes float functions to double. */
/* Note that VAX/VMS, IBM, Mips choke on 'type function(...);' prototypes. */
#define CF_VOID_PROTO void
#define CF_NULL_PROTO ...
#ifndef __CF__APOLLO67
#define COMMON_BLOCK_DEF(DEFINITION, NAME) \
...
...
@@ -766,7 +768,7 @@ return (int)num;
while the following equivalent typedef is fine.
For consistency use the typedef on all machines.
*/
typedef
void
(
*
cfCAST_FUNCTION
)(
CF_
NULL
_PROTO
);
typedef
void
(
*
cfCAST_FUNCTION
)(
CF_
VOID
_PROTO
);
#define VCF(TN,I) _Icf4(4,V,TN,_(A,I),_(B,I),F)
#define VVCF(TN,AI,BI) _Icf4(4,V,TN,AI,BI,S)
...
...
@@ -781,7 +783,7 @@ typedef void (*cfCAST_FUNCTION)(CF_NULL_PROTO);
#define PINT_cfV( T,A,B,F) _(T,_cfVP)(A,B)
#define PVOID_cfV( T,A,B,F)
#if defined(apolloFortran) || defined(hpuxFortran800) || defined(AbsoftUNIXFortran) || defined(AbsoftProFortran)
#define ROUTINE_cfV(T,A,B,F) void (*B)(CF_
NULL
_PROTO) = (cfCAST_FUNCTION)A;
#define ROUTINE_cfV(T,A,B,F) void (*B)(CF_
VOID
_PROTO) = (cfCAST_FUNCTION)A;
#else
#define ROUTINE_cfV(T,A,B,F)
#endif
...
...
@@ -1223,7 +1225,7 @@ typedef void (*cfCAST_FUNCTION)(CF_NULL_PROTO);
/* Note: Prevent compiler warnings, null #define PROTOCCALLSFSUB14/20 after
#include-ing cfortran.h if calling the FORTRAN wrapper within the same
source code where the wrapper is created. */
#define PROTOCCALLSFSUB0(UN,LN) _(VOID,_cfPU)(CFC_(UN,LN))();
#define PROTOCCALLSFSUB0(UN,LN) _(VOID,_cfPU)(CFC_(UN,LN))(
CF_VOID_PROTO
);
#ifndef __CF__KnR
#define PROTOCCALLSFSUB14(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE) \
_(VOID,_cfPU)(CFC_(UN,LN))( CFARGT14(NCF,KCF,_Z,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE) );
...
...
@@ -1997,8 +1999,8 @@ for the same function in the same source code. Something done by the experts in
debugging only.*/
#define PROTOCCALLSFFUN0(F,UN,LN) \
_(F,_cfPU)( CFC_(UN,LN))(CF_
NULL
_PROTO); \
static _Icf(2,U,F,CFFUN(UN),0)() {_(F,_cfE) _Icf(3,GZ,F,UN,LN) ABSOFT_cf1(F));_(F,_cfX)}
_(F,_cfPU)( CFC_(UN,LN))(CF_
VOID
_PROTO); \
static _Icf(2,U,F,CFFUN(UN),0)(
CF_VOID_PROTO
) {_(F,_cfE) _Icf(3,GZ,F,UN,LN) ABSOFT_cf1(F));_(F,_cfX)}
#define PROTOCCALLSFFUN1( T0,UN,LN,T1) \
PROTOCCALLSFFUN5 (T0,UN,LN,T1,CF_0,CF_0,CF_0,CF_0)
...
...
@@ -2030,8 +2032,8 @@ static _Icf(2,U,F,CFFUN(UN),0)() {_(F,_cfE) _Icf(3,GZ,F,UN,LN) ABSOFT_cf1(F));_(
/* HP/UX 9.01 cc requires the blank between '_Icf(3,G,T0,UN,LN) CCCF(T1,1,0)' */
#ifndef __CF__KnR
#define PROTOCCALLSFFUN14(T0,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE)
\
_(T0,_cfPU)(CFC_(UN,LN))(CF
_NULL_PROTO
); static _Icf(2,U,T0,CFFUN(UN),0)(
\
#define PROTOCCALLSFFUN14(T0,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE) \
_(T0,_cfPU)(CFC_(UN,LN))(CF
ARGT14(NCF,DCF,ABSOFT_cf2(T0),T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE)
); static _Icf(2,U,T0,CFFUN(UN),0)( \
CFARGT14FS(UCF,HCF,_Z,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE) ) \
{ CFARGT14S(VCF,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE) _(T0,_cfE) \
CCF(LN,T1,1) CCF(LN,T2,2) CCF(LN,T3,3) CCF(LN,T4,4) CCF(LN,T5,5) \
...
...
@@ -2256,23 +2258,18 @@ static _Icf(2,U,F,CFFUN(UN),0)() {_(F,_cfE) _Icf(3,GZ,F,UN,LN) ABSOFT_cf1(F));_(
#define PNSTRING_cfR(A,B,D) PSTRING_cfR(A,B,D)
#define PPSTRING_cfR(A,B,D)
#define BYTE_cfFZ(UN,LN)
INTEGER_BYTE FCALLSC_QUALIFIER fcallsc
(UN,LN)
(
#define DOUBLE_cfFZ(UN,LN) DOUBLE_
PRECISION FCALLSC_QUALIFIER fcallsc
(UN,LN)
(
#define INT_cfFZ(UN,LN)
int FCALLSC_QUALIFIER fcallsc
(UN,LN)
(
#define LOGICAL_cfFZ(UN,LN)
int FCALLSC_QUALIFIER fcallsc
(UN,LN)
(
#define LONG_cfFZ(UN,LN)
long FCALLSC_QUALIFIER fcallsc
(UN,LN)
(
#define LONGLONG_cfFZ(UN,LN) LONGLONG
FCALLSC_QUALIFIER fcallsc
(UN,LN)
(
/* added by MR December 2005 */
#define SHORT_cfFZ(UN,LN)
short FCALLSC_QUALIFIER fcallsc
(UN,LN)
(
#define VOID_cfFZ(UN,LN)
void FCALLSC_QUALIFIER fcallsc
(UN,LN)
(
#define BYTE_cfFZ(UN,LN)
BYTE_cfF
(UN,LN)
void
#define DOUBLE_cfFZ(UN,LN)
DOUBLE_
cfF
(UN,LN)
void
#define INT_cfFZ(UN,LN)
INT_cfF
(UN,LN)
void
#define LOGICAL_cfFZ(UN,LN)
LOGICAL_cfF
(UN,LN)
void
#define LONG_cfFZ(UN,LN)
LONG_cfF
(UN,LN)
void
#define LONGLONG_cfFZ(UN,LN) LONGLONG
_cfF
(UN,LN)
void
/* added by MR December 2005 */
#define SHORT_cfFZ(UN,LN)
SHORT_cfF
(UN,LN)
void
#define VOID_cfFZ(UN,LN)
VOID_cfF
(UN,LN)
void
#ifndef __CF__KnR
/* The void is req'd by the Apollo, to make this an ANSI function declaration.
The Apollo promotes K&R float functions to double. */
#if defined (f2cFortran) && ! defined (gFortran)
/* f2c/g77 return double from FORTRAN REAL functions. (KMCCARTY, 2005/12/09) */
#define FLOAT_cfFZ(UN,LN) DOUBLE_PRECISION FCALLSC_QUALIFIER fcallsc(UN,LN)(void
#else
#define FLOAT_cfFZ(UN,LN) FORTRAN_REAL FCALLSC_QUALIFIER fcallsc(UN,LN)(void
#endif
/* The void is req'd by the Apollo, to make this an ANSI function declaration. */
#define FLOAT_cfFZ(UN,LN) FLOAT_cfF(UN,LN)void
#ifdef vmsFortran
#define STRING_cfFZ(UN,LN) void FCALLSC_QUALIFIER fcallsc(UN,LN)(fstring *AS
#else
...
...
@@ -2287,16 +2284,7 @@ static _Icf(2,U,F,CFFUN(UN),0)() {_(F,_cfE) _Icf(3,GZ,F,UN,LN) ABSOFT_cf1(F));_(
#endif
#endif
#else
#if ! (defined(FLOATFUNCTIONTYPE)&&defined(ASSIGNFLOAT)&&defined(RETURNFLOAT))
#if defined (f2cFortran) && ! defined (gFortran)
/* f2c/g77 return double from FORTRAN REAL functions. (KMCCARTY, 2005/12/09) */
#define FLOAT_cfFZ(UN,LN) DOUBLE_PRECISION FCALLSC_QUALIFIER fcallsc(UN,LN)(
#else
#define FLOAT_cfFZ(UN,LN) FORTRAN_REAL FCALLSC_QUALIFIER fcallsc(UN,LN)(
#endif
#else
#define FLOAT_cfFZ(UN,LN) FLOATFUNCTIONTYPE FCALLSC_QUALIFIER fcallsc(UN,LN)(
#endif
#define FLOAT_cfFZ(UN,LN) FLOAT_cfF(UN,LN)
#if defined(vmsFortran) || defined(CRAYFortran) || defined(AbsoftUNIXFortran)
#define STRING_cfFZ(UN,LN) void FCALLSC_QUALIFIER fcallsc(UN,LN)(AS
#else
...
...
@@ -2304,24 +2292,25 @@ static _Icf(2,U,F,CFFUN(UN),0)() {_(F,_cfE) _Icf(3,GZ,F,UN,LN) ABSOFT_cf1(F));_(
#endif
#endif
#define BYTE_cfF(UN,LN)
BYTE_cfFZ
(UN,LN)
#define DOUBLE_cfF(UN,LN)
DOUBLE_
cfFZ
(UN,LN)
#define BYTE_cfF(UN,LN)
INTEGER_BYTE FCALLSC_QUALIFIER fcallsc
(UN,LN)
(
#define DOUBLE_cfF(UN,LN) DOUBLE_
PRECISION FCALLSC_QUALIFIER fcallsc
(UN,LN)
(
#ifndef __CF_KnR
#if defined (f2cFortran) && ! defined (gFortran)
/* The Apollo promotes K&R float functions to double. */
/* f2c/g77 return double from FORTRAN REAL functions. (KMCCARTY, 2005/12/09) */
#define FLOAT_cfF(UN,LN) DOUBLE_PRECISION FCALLSC_QUALIFIER fcallsc(UN,LN)(
#else
#define FLOAT_cfF(UN,LN) FORTRAN_REAL FCALLSC_QUALIFIER fcallsc(UN,LN)(
#endif
#else
#define FLOAT_cfF(UN,LN)
FLOAT
_cfFZ
(UN,LN)
#define FLOAT_cfF(UN,LN) FLOAT
FUNCTIONTYPE FCALLSC_QUALIFIER fcallsc
(UN,LN)
(
#endif
#define INT_cfF(UN,LN)
INT_cfFZ
(UN,LN)
#define LOGICAL_cfF(UN,LN)
LOGICAL_cfFZ
(UN,LN)
#define LONG_cfF(UN,LN)
LONG_cfFZ
(UN,LN)
#define LONGLONG_cfF(UN,LN) LONGLONG
_cfFZ
(UN,LN)
/* added by MR December 2005 */
#define SHORT_cfF(UN,LN)
SHORT_cfFZ
(UN,LN)
#define VOID_cfF(UN,LN)
VOID_cfFZ
(UN,LN)
#define INT_cfF(UN,LN)
int FCALLSC_QUALIFIER fcallsc
(UN,LN)
(
#define LOGICAL_cfF(UN,LN)
int FCALLSC_QUALIFIER fcallsc
(UN,LN)
(
#define LONG_cfF(UN,LN)
long FCALLSC_QUALIFIER fcallsc
(UN,LN)
(
#define LONGLONG_cfF(UN,LN) LONGLONG
FCALLSC_QUALIFIER fcallsc
(UN,LN)
(
/* added by MR December 2005 */
#define SHORT_cfF(UN,LN)
short FCALLSC_QUALIFIER fcallsc
(UN,LN)
(
#define VOID_cfF(UN,LN)
void FCALLSC_QUALIFIER fcallsc
(UN,LN)
(
#define STRING_cfF(UN,LN) STRING_cfFZ(UN,LN),
#define INT_cfFF
...
...
@@ -2500,11 +2489,20 @@ string. */
#ifndef __CF__KnR
#define FCALLSCFUN0(T0,CN,UN,LN) CFextern _(T0,_cfFZ)(UN,LN) ABSOFT_cf2(T0)) \
#if defined(AbsoftUNIXFortran) || defined(AbsoftProFortran)
#define FCALLSCFUN0(T0,CN,UN,LN) CFextern _(T0,_cfFZ)(UN,LN) ABSOFT_cf2(T0)); \
CFextern _(T0,_cfFZ)(UN,LN) ABSOFT_cf2(T0)) \
{_Icf(2,UU,T0,A0,0); _Icf(0,L,T0,0,0) CN(); _Icf(0,K,T0,0,0) _(T0,_cfI)}
#else
#define FCALLSCFUN0(T0,CN,UN,LN) CFextern _(T0,_cfFZ)(UN,LN)); \
CFextern _(T0,_cfFZ)(UN,LN)) \
{_Icf(2,UU,T0,A0,0); _Icf(0,L,T0,0,0) CN(); _Icf(0,K,T0,0,0) _(T0,_cfI)}
#endif
#define FCALLSCFUN14(T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE) \
CFextern _(T0,_cfF)(UN,LN) \
CFARGT14(NCF,DCF,ABSOFT_cf2(T0),T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE) ); \
CFextern _(T0,_cfF)(UN,LN) \
CFARGT14(NCF,DCF,ABSOFT_cf2(T0),T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE) ) \
{ CFARGT14S(QCF,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE) \
_Icf(2,UU,T0,A0,0); _Icf(0,L,T0,0,0) CN( TCF(LN,T1,1,0) TCF(LN,T2,2,1) \
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment