The suggested revisions to the cfitsio2.h file will be included in the next release of CFITSIO in December. A beta pre-release version is available on the CFITSIO web page at http://heasarc.gsfc.nasa.gov/fitsio/ if anyone wants to test it (I do not have access to a MIPS or ARM machine, so I have not
tested this myself).

Note one additional change is necessary in the diffs shown below in the ARM case: if BYTESWAPPED is TRUE, then MACHINE should not be defined. (In particular, it should not be defined as NATIVE). If BTYPESWAPPED is FALSE, then it would not hurt to also define MACHINE == NATIVE, but this is not critical.

The new version of fitsio2.h assumes that ARM are always little-endian. If necessary, a further test for ARMEL could be added to distinguish the little and big endian variants. In researching this issue on the Web I saw some references to ARM machines where the integers are big-endian but IEEE floating points are little-endian (or vice-versa). CFITSIO would not work on these machines because it assumes that floats and integers always have the same endian-ness,

It would be risky to change CFITSIO to rely solely on endian.h to determine the byte order, because older machines (and especially non-unix machines) may not have an endian.h include file. It might be possible to add another "elif defined(__byte_order)" case to cover new machines that get introduced in the future. I'll consider this for a future release.

Bill Pence

Faidon Liambotis wrote:
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 */


--
____________________________________________________________________
Dr. William Pence                       [EMAIL PROTECTED]
NASA/GSFC Code 662       HEASARC        +1-301-286-4599 (voice)
Greenbelt MD 20771                      +1-301-286-1684 (fax)




--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to