[comp.lang.c] HP-UX Fortran/C Procedure Calling Protocol

billc@wupulm.UUCP (Bill Canning) (06/30/89)

Could someone out there tell me how FORTRAN/9000 expects
functions to return thier values?  Is it in the same
registers that C would return the same type of value,
(e.g., INTEGER*4 returned in register D0 by FORTRAN,
long int returned in reg. D0 in C.)  I am trying to
port some code that is written in both FORTRAN and
C, originally created on Data General equipment.

Any help someone could offer would be greatly appreciated.

Thanks in advance,
Bill Canning
..!uunet!wugate!wupost!wupulm!billc

mike@hpfcdc.HP.COM (Mike McNelly) (07/05/89)

> Could someone out there tell me how FORTRAN/9000 expects
> functions to return thier values?  Is it in the same
> registers that C would return the same type of value,
> (e.g., INTEGER*4 returned in register D0 by FORTRAN,
> long int returned in reg. D0 in C.)  I am trying to
> port some code that is written in both FORTRAN and
> C, originally created on Data General equipment.

> Any help someone could offer would be greatly appreciated.

C and FORTRAN share the same calling conventions on HP-UX 9000 Series
300 but you have to remember that C is normally call by value and
FORTRAN is normally call by reference.  Function values are returned in
the same registers.

For your porting effort, I'd strongly suggest that you pick up two HP
manuals:  1) HP-UX Portability Guide for HP 9000 Series 300/800
computers (Part Number 98794-90046), which discusses a lot of language
porting issues such as data type sizes and alignments, features, etc.;
and 2) HP-UX Assembler Reference and Supporting Documents (Part Number
98597-90020)m which discusses calling code conventions for the
languages.  These are detailed discussions.

Mike McNelly
mike%hpfcla@hplabs.hp.com