Oliver Paukstadt on Mon, 10 Dec 2001 13:59:53 +0100 (CET)


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

New 64 Bit Big Endian architecture


HY HY

I'm porting various software to a very new architecture, it's Linux for
zSeries (64 bit). zSeries is IBMs 64 bit successor to 31 Bit S/390.

s390x is a 64 bit big endian architecture.

I ported a complete RedHat 7.1 to this architecture, this Distribution is
named ThinkBlue/64 and available from http://linux.zSeries.org/
It is the only Distribution for this Hardware available in 64 Bit, RedHat
and SuSE only announced or deliver Beta-Code.
ThinkBlue/64 Customers run SAP Application-Server for Linux for zSeries on
it.

Now I started to test CPAN-Modules and always fell over Math::Pari and
especially pari-2.1.2

First thing is, that config/endian.c is ugly and wrong.
I'm not sure, what you really want to find out, but ia64 (64 bit
LittleEndian) and s390x (64 bit BigEndian) have the same output.

Imho float representation is independent from byteorder of integer values.
If you have special assumption for floats please put it into another test.
I have a test-prg based on det-endian.c of glibc which works correct for
32 and 64 bit endian detection.

s390 requires -fPIC for shared code.

All test seem to be successful, except nfields.
If you want the diffs please ask for it.

Here are the inital s390x patches (If the mailer destroys them, ask for a
attached patch-file).
-snip---
diff -Nur pari-2.1.2/Configure pari-2.1.2.work/Configure
diff -Nur pari-2.1.2/config/endian.c pari-2.1.2.work/config/endian.c
[root@z03 pari]# cat /tmp/pari.patch
--- pari-2.1.2.orig/Configure	Mon Oct 15 21:36:16 2001
+++ pari-2.1.2/Configure	Mon Dec 10 13:45:25 2001
@@ -845,6 +845,8 @@
   case "$osname-$arch" in
     linux-i?86|cygwin*) OPTFLAGS="$OPTFLAGS \
       -malign-loops=2 -malign-jumps=2 -malign-functions=2";;
+    linux-s390*) DLCFLAGS=-fPIC;
+                 OPTFLAGS="$OPTFLAGS -mno-backchain";;
     os2-*) cflags=-Zmt;;
     *-sparcv8*) cflags=-mv8;;
   esac
@@ -1120,7 +1122,7 @@
 echo "The internal byte representation of a double is $endian."

 case $endian in
-  *8) sizeof_long=8; pretty="$pretty 64-bit version";;
+  *8|8*) sizeof_long=8; pretty="$pretty 64-bit version";;
   *)  sizeof_long=4; pretty="$pretty 32-bit version";;
 esac

--- pari-2.1.2.orig/config/endian.c	Fri Oct 12 21:26:45 2001
+++ pari-2.1.2/config/endian.c	Mon Dec 10 13:53:19 2001
@@ -1,21 +1,27 @@
-main()
+/* Determine the "endianness" of the CPU.
+   Based upon the det_endian.c from glibc
+   Copyright in 2001 by Oliver Paukstadt
+   Based upon the det_endian.c from glibc
+     contributed by Torbjorn Granlund (tege@sics.se)
+   64 bit part from Oliver Paukstadt <software@paukstadt.de>
+
+   Licensed under the terms of GPL v2.
+*/
+
+#include <stdio.h>
+
+main ()
 {
-  if (sizeof(long) == 4)
-  {
-    union { double f; unsigned long i[2] } fi;
-    fi.f = 2.;
-    if (fi.i[0]==0 && fi.i[1]==(1UL<<30)) printf("1234\n");
-    else if (fi.i[1]==0 && fi.i[0]==(1UL<<30)) printf("4321\n");
-    else
-      printf("UNKNOWN\n");
+  unsigned long int i;
+  if (sizeof (i) == 4) {
+    i = (((((('4' << 8) + '3') << 8) + '2') << 8) + '1');
+    printf ("%.4s\n", (char *) &i);
+  } else
+  if (sizeof (i) == 8) {
+    i = ((((((((((((((unsigned long int)('8' << 8) + '7') << 8) + '6') <<
8) + '5') << 8) + '4' ) << 8) + '3') << 8) + '2') << 8) + '1');
+    printf ("%.8s\n", (char *) &i);
+  } else {
+    printf("UNKNOWN\n");
   }
-  else
-  {
-    union { double f; unsigned long i } fi;
-    fi.f = 2.;
-    if (fi.i==(1UL<<62)) printf("12345678\n");
-    else
-      printf("UNKNOWN\n");
-  }
-  exit(0);
-}
+
+}
-snip---


Greetings
Oliver Paukstadt

+++There is this special biologist word we use for 'stable'. +++++++++++++
+++It is 'dead'. -- Jack Cohen +++++++++++++++++++++++++++++++++++++++++++
+++oliver@paukstadt.de+++http://www.paukstadt.de/ ++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++