Author: Alastair McKinstry <mckinstry@debian.org>
Description: Use __BYTE_ORDER to build on non-specfied architectures
Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=650558
Last-Updated: 2011-12-09
Forwarded: no

Index: ccseapps/CCSEApps/BoxLib/FPC.cpp
===================================================================
--- ccseapps.orig/CCSEApps/BoxLib/FPC.cpp	2006-01-11 19:13:06.000000000 +0000
+++ ccseapps/CCSEApps/BoxLib/FPC.cpp	2011-12-09 10:48:46.000000000 +0000
@@ -25,6 +25,7 @@
 //
 
 #include <FPC.H>
+#include <endian.h>
 //
 // FP orders.
 //
@@ -51,11 +52,14 @@
 //
 
 
+// For non-specifically defined systems, assume that middle-endian ordering is no longer
+// used, and rely on __BYTE_ORDER working
+
 const
 IntDescriptor&
 FPC::NativeLongDescriptor ()
 {
-#if defined(__alpha) || defined(__i486__) || defined(WIN32) || defined(i386) || defined(__i386__) || defined(__ia64__) || defined(__x86_64__)
+#if (defined(__alpha) || defined(__i486__) || defined(WIN32) || defined(i386) || defined(__i386__) || defined(__ia64__) || defined(__x86_64__)) || (__BYTE_ORDER == __LITTLE_ENDIAN) 
     static const IntDescriptor nld(sizeof(long), IntDescriptor::ReverseOrder);
 #endif
 
@@ -63,11 +67,14 @@
     static const IntDescriptor nld(sizeof(long), IntDescriptor::NormalOrder);
 #endif
 
-#if defined(__sgi) || \
+#if ( defined(__sgi) || \
     defined(__sun) || \
     defined(_AIX)  || \
     defined(_CRAYT3E)  || \
-    defined(__hpux)
+    defined(__hpux) || \
+    defined(__hppa__) || \
+    defined(__m68k__) ) || \
+      ( __BYTE_ORDER == __BIG_ENDIAN )
     static const IntDescriptor  nld(sizeof(long), IntDescriptor::NormalOrder);
 #endif
 
@@ -78,7 +85,7 @@
 RealDescriptor&
 FPC::NativeRealDescriptor ()
 {
-#if defined(__alpha) || defined(__i486__) || defined(WIN32) || defined(i386) || defined(__i386__) || defined(__ia64__) || defined(__x86_64__)
+#if (defined(__alpha) || defined(__i486__) || defined(WIN32) || defined(i386) || defined(__i386__) || defined(__ia64__) || defined(__x86_64__)) || ( __BYTE_ORDER == __LITTLE_ENDIAN)
 #ifdef BL_USE_FLOAT
     static const RealDescriptor nrd(ieee_float, reverse_float_order, 4);
 #else
@@ -90,11 +97,11 @@
     static const RealDescriptor nrd(cray_float, cray_float_order, 8);
 #endif
 
-#if defined(__sgi) || \
+#if (defined(__sgi) || \
     defined(__sun) || \
     defined(_AIX)  || \
     defined(_CRAYT3E)  || \
-    defined(__hpux)
+    defined(__hpux) ) || ( __BYTE_ORDER == __BIG_ENDIAN)
 #ifdef BL_USE_FLOAT
     static const RealDescriptor nrd(ieee_float, normal_float_order, 4);
 #else
@@ -129,7 +136,6 @@
     return i64rd;
 }
 
-
 //
 // TODO -- add more machine descriptions.
 //
@@ -145,7 +151,8 @@
       defined(__x86_64__) || \
       defined(__hpux)     || \
       defined(_MSC_VER)   || \
-      defined(_AIX))
-#error We do not yet support FAB I/O on this machine
+      defined(_AIX)) 
+#warning "Assuming floating-point order from byte-order"
+
 #endif
 
