f2c for Opteron patch under Linux

From: wkpark (wkpark_at_kldp.org)
Date: 07/20/04


Date: 19 Jul 2004 20:18:37 -0700

Hello

I made a 64bit enabled f2c patch

I just modified f2c source and some bug fixes against libf2c

It redefines "integer" "longint" found in the "f2c.h" as following
------
typedef long int integer;
typedef unsigned long int uinteger;
typedef char *address;
typedef short int shortint;
/* typedef float real; */
typedef double real;
typedef double doublereal;
------
with this patch, f2c interpret integer and real variables as integer*8
and real*8 (like other f77 compiler's "-i8 -r8" option)

attached patches contain following:
 * f2c with the gcc-3.4 patch
 * etime_.c real patch.
 * http://gcc.gnu.org/PR15151 describe wrtfmt.c bug on AMD64
 * modified libf2c/lio.c to adjust similar output as the pgf77 and DEC
f77.

This patched f2c works fine with the GAMESS and Gaussian 98 with
fedora core2.
----------- 8x ------------------
diff -ur f2c/src/format.c f2c/src.new/format.c
--- f2c/src/format.c 2003-03-21 03:34:13.000000000 +0900
+++ f2c/src.new/format.c 2004-07-16 09:50:56.935975424 +0900
@@ -2506,6 +2506,11 @@

        atypes = at->atypes;
        nice_printf(outfile, "(");
+#if 1
+/* for gcc 3.4 */
+ nice_printf(outfile, ")");
+ return;
+#else
        comma = "";
        for(; --n >= 0; atypes++) {
                k = atypes->type;
@@ -2528,6 +2533,7 @@
                comma = ", ";
                }
        nice_printf(outfile, ")");
+#endif
        }

  void
diff -ur f2c/src/init.c f2c/src.new/init.c
+++ f2c/src.new/init.c 2004-07-19 01:08:11.220064088 +0900
@@ -81,10 +81,25 @@
 int typesize[NTYPES] = {
        1, SZADDR, 1, SZSHORT, SZLONG,
 #ifdef TYQUAD
+#ifdef __x86_64__
+ SZLONG,
+#else
                2*SZLONG,
 #endif
- SZLONG, 2*SZLONG,
- 2*SZLONG, 4*SZLONG, 1, SZSHORT, SZLONG, 1, 1, 0,
+#endif
+ SZLONG,
+#ifdef __x86_64__
+ SZLONG,
+#else
+ 2*SZLONG,
+#endif
+ 2*SZLONG,
+#ifdef __x86_64__
+ 2*SZLONG,
+#else
+ 4*SZLONG,
+#endif
+ 1, SZSHORT, SZLONG, 1, 1, 0,
                4*SZLONG + SZADDR, /* sizeof(cilist) */
                4*SZLONG + 2*SZADDR, /* sizeof(icilist) */
                4*SZLONG + 5*SZADDR, /* sizeof(olist) */
@@ -96,8 +111,12 @@
 int typealign[NTYPES] = {
        1, ALIADDR, 1, ALISHORT, ALILONG,
 #ifdef TYQUAD
+#ifdef __x86_64__
+ ALILONG,
+#else
        ALIDOUBLE,
 #endif
+#endif
        ALILONG, ALIDOUBLE,
        ALILONG, ALIDOUBLE, 1, ALISHORT, ALILONG, 1, 1, 1,
        ALILONG, ALILONG, ALILONG, ALILONG, ALILONG, ALILONG};
diff -ur f2c/src/machdefs.h f2c/src.new/machdefs.h
--- f2c/src/machdefs.h 1990-01-22 04:21:06.000000000 +0900
+++ f2c/src.new/machdefs.h 2004-07-19 01:05:20.759977960 +0900
@@ -1,11 +1,21 @@
 #define TYLENG TYLONG /* char string length field */

 #define TYINT TYLONG
+#ifdef __x86_64__
+#define SZADDR 8
+#else
 #define SZADDR 4
+#endif
+
 #define SZSHORT 2
 #define SZINT 4

+#ifdef __x86_64__
+#define SZLONG 8
+#else
 #define SZLONG 4
+#endif
+
 #define SZLENG SZLONG

 #define SZDREAL 8
@@ -14,7 +24,11 @@

 #define ALIADDR SZADDR
 #define ALISHORT SZSHORT
+#ifdef __x86_64__
+#define ALILONG 8
+#else
 #define ALILONG 4
+#endif
 #define ALIDOUBLE 8
 #define ALIINT ALILONG
 #define ALILENG ALILONG
diff -ru f2c/libf2c/etime_.c f2c/libf2c.new/etime_.c
--- f2c/libf2c/etime_.c 2000-09-29 23:36:22.000000000 +0900
+++ f2c/libf2c.new/etime_.c 2004-07-18 18:31:14.420767000 +0900
@@ -32,9 +32,9 @@

  REAL
 #ifdef KR_headers
-etime_(tarray) float *tarray;
+etime_(tarray) real *tarray;
 #else
-etime_(float *tarray)
+etime_(real *tarray)
 #endif
 {
 #ifdef USE_CLOCK
diff -u f2c/libf2c/lio.h f2c/libf2c.n/lio.h
--- f2c/libf2c/lio.h 1995-09-06 15:34:26.000000000 +0900
+++ f2c/libf2c.n/lio.h 2004-07-19 01:49:45.640854488 +0900
@@ -36,7 +36,7 @@
 #define LEFMT " %# .8E"
 #define LFFMT " %# .9g"
 #else
-#define LGFMT "%.9G"
+#define LGFMT "%# .17G"
 #endif
 /* LEFBL 20 should suffice; 24 overcomes a NeXT bug. */
 #define LEFBL 24
--- f2c/src/f2c.h 1999-09-08 02:46:24.000000000 +0900
+++ f2c/src.new/f2c.h 2004-07-19 03:24:08.144023160 +0900
@@ -11,7 +11,11 @@
 typedef unsigned long int uinteger;
 typedef char *address;
 typedef short int shortint;
+#ifdef __x86_64__
+typedef double real;
+#else
 typedef float real;
+#endif
 typedef double doublereal;
 typedef struct { real r, i; } complex;
 typedef struct { doublereal r, i; } doublecomplex;
diff -ru f2c/libf2c/wrtfmt.c f2c/libf2c.new/wrtfmt.c
--- f2c/libf2c/wrtfmt.c 2000-07-04 22:04:56.000000000 +0900
+++ f2c/libf2c.new/wrtfmt.c 2004-07-18 18:20:54.576998000 +0900
@@ -228,9 +228,14 @@
 wrt_L(Uint *n, int len, ftnlen sz)
 #endif
 { int i;
- long x;
- if(sizeof(long)==sz) x=n->il;
- else if(sz == sizeof(char)) x = n->ic;
+ longint x;
+
+#ifdef Allow_TYQUAD
+ if (sizeof (longint) == sz) x = n->ili;
+ else
+#endif
+ if(sizeof(integer)==sz) x=n->il;
+ else if(sizeof(char)==sz) x = n->ic;
        else x=n->is;
        for(i=0;i<len-1;i++)
                (*f__putn)(' ');
-------------------------------------------------- end ----



Relevant Pages

  • [patch 1/1] consolidate TRUE and FALSE
    ... int main ... typedef struct { ... struct gemtek_pci_card { ...
    (Linux-Kernel)
  • Bypassing Personal Firewalls
    ... typedef SOCKET (int, int, int); ... typedef int (__stdcall *func_connect)(SOCKET, const struct sockaddr ... typedef HANDLE (LPCTSTR, DWORD, DWORD, ...
    (Bugtraq)
  • Bypassing Personal Firewalls
    ... typedef SOCKET (int, int, int); ... typedef int (__stdcall *func_connect)(SOCKET, const struct sockaddr ... typedef HANDLE (LPCTSTR, DWORD, DWORD, ...
    (Vuln-Dev)
  • Re: "Portability" contructs like UINT32 etc.
    ... > typedef char CHAR; ... > typedef int INT32; ... > typedef char* PCHAR; ... Both processors had hardware alignment requirements. ...
    (comp.lang.c)
  • Re: SymGetTypeInfo and TI_GET_SYMNAME
    ... typedef int MyType; ... typedef MyStruct MyStruct2; ... Now i succed to have information about struct and typedef. ...
    (microsoft.public.vsnet.debugging)