Attached are two separate patches: one for cfitsio 2.510-1 and one for
cfitsio3 3.006-1.1.
The previous approach that was applied to cfitsio3 (and only that) had
two problems; the first one, regarding MIPSEL, was that it was handled
in an "elif" case, while MIPS was already handled in a previous
condition. The second one, regarding ARM, was that it was checking for
"defined(arm)" instead of "defined(__arm__)".

The patches fix both of these issues. However, they make the assumption
that ARM is always Little-Endian which is not true. arm big-endian is
not currently an official Debian port though, which makes the issue non-RC.

The patches are neither compile tested or runtime tested.
I'm currently trying to test them on vaughan, one of Debian's mipsel
development machine which has the necessary build dependencies (unlike
casals (mips) and leisner (arm) which lack them). The machine's speed
doesn't help though :-(

Dr. Pence, I would suggest to use endian.h and __BYTE_ORDER to check for
 endianness instead of hard-coding each variant of every architecture in
the world. This would help avoid current and future problems.

Regards,
Faidon
--- fitsio2.h   2006-11-11 00:43:42.000000000 +0200
+++ fitsio2.h   2006-11-11 00:51:02.000000000 +0200
@@ -79,7 +79,11 @@
 
 #elif defined(_MIPS_SZLONG)
 
-#define BYTESWAPPED FALSE
+#if defined(MIPSEL)
+#  define BYTESWAPPED TRUE
+#elif
+#  define BYTESWAPPED FALSE
+#endif
 #  if _MIPS_SZLONG == 32
 #    define LONGSIZE 32
 #  elif _MIPS_SZLONG == 64
@@ -125,13 +129,18 @@
  
 #elif defined(__i386) || defined(__i386__) || defined(__i486__) || 
defined(__i586__) \
   || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__TURBOC__) \
-  || defined(_NI_mswin_) || defined(__EMX__) \
-  || defined(MIPSEL)     || defined(arm)
+  || defined(_NI_mswin_) || defined(__EMX__)
 
 /*  generic 32-bit IBM PC */
 #define MACHINE IBMPC
 #define BYTESWAPPED TRUE
 
+#elif defined(__arm__)
+
+/*  ARM Little-endian */
+#define MACHINE NATIVE
+#define BYTESWAPPED TRUE
+
 #else
 
 /* ========================================================================== 
*/
--- fitsio2.h   2006-11-11 00:46:44.000000000 +0200
+++ fitsio2.h   2006-11-11 00:49:38.000000000 +0200
@@ -52,6 +52,11 @@
 
 /* the following block determines the size of longs on SGI IRIX machines */
 #if defined(_MIPS_SZLONG)
+#  if defined(MIPSEL)
+#    define BYTESWAPPED TRUE
+#  elif
+#    define BYTESWAPPED FALSE
+#  endif
 #  if _MIPS_SZLONG == 32
 #    define LONGSIZE 32
 #  elif _MIPS_SZLONG == 64
@@ -132,6 +137,12 @@
 #define MACHINE PC64BIT
 #define LONGSIZE 64   
 
+#elif defined(__arm__)
+
+/*  ARM Little-endian */
+#define MACHINE NATIVE
+#define BYTESWAPPED TRUE
+ 
 #else
 
 /*  assume machine uses the same IEEE formats as used in FITS files */

Reply via email to