This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RFC: 64-bit variables in libf2c


Hi,

on 64-bit machines, some programs in Fortran with direct access IO and
recordlength > 2 GB abort in read (c_due()) because
 (cast to 32-bit int) 64-bit_value < 0.

So I tried to replace some types with 64-bit types for IO functions,
see the attached patch. But the 64-bit types are used also on 32-bit
targets :-(
Probably we should use there something like HOST_WIDE_INT,
i.e. 32-bit on 32-bit machines, 64-bit on 64-bit machines.

Following patch uses 64-bit values for the IO functions.
But it uses them also on 32-bit targets :-(
We should use something like HOST_WIDE_INT here.
But in Fortran we have a wired in __g77_integer which is "always"
32-bit, and __g77_longint which is "always" 64-bit ("always" means on
all usual platforms, like i386, x86-64, and probably ppc, alpha, ...).

Although the patch bootstrapped on x86-64 and the testcase was compiled
correctly with 64-bit values, I do not know whether it is correct, since
I do not know Fortran standard.

Josef

Index: gcc/f/com.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/f/com.h,v
retrieving revision 1.28
diff -c -3 -p -r1.28 com.h
*** gcc/f/com.h	22 Mar 2003 13:01:07 -0000	1.28
--- gcc/f/com.h	20 May 2003 06:50:02 -0000
*************** the Free Software Foundation, 59 Temple 
*** 103,110 ****
  /* These must be f2c's INTEGER type, to match runtime/f2c.h.in.  */
  
  #define FFECOM_f2cFLAG FFECOM_f2cINTEGER
! #define FFECOM_f2cFTNINT FFECOM_f2cINTEGER
! #define FFECOM_f2cFTNLEN FFECOM_f2cINTEGER
  
  #endif	/* #if FFECOM_DETERMINE_TYPES */
  
--- 103,110 ----
  /* These must be f2c's INTEGER type, to match runtime/f2c.h.in.  */
  
  #define FFECOM_f2cFLAG FFECOM_f2cINTEGER
! #define FFECOM_f2cFTNINT FFECOM_f2cLONGINT
! #define FFECOM_f2cFTNLEN FFECOM_f2cLONGINT
  
  #endif	/* #if FFECOM_DETERMINE_TYPES */
  
Index: libf2c/g2c.hin
===================================================================
RCS file: /cvs/gcc/gcc/libf2c/g2c.hin,v
retrieving revision 1.4
diff -c -3 -p -r1.4 g2c.hin
*** libf2c/g2c.hin	1 Jun 2002 01:58:09 -0000	1.4
--- libf2c/g2c.hin	20 May 2003 06:50:03 -0000
*************** typedef short ftnlen;
*** 53,60 ****
  typedef short ftnint;
  #else
  typedef __g77_integer flag;
! typedef __g77_integer ftnlen;
! typedef __g77_integer ftnint;
  #endif
  
  /*external read, write*/
--- 53,60 ----
  typedef short ftnint;
  #else
  typedef __g77_integer flag;
! typedef __g77_longint ftnlen;
! typedef __g77_longint ftnint;
  #endif
  
  /*external read, write*/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]