diff src/sysdep.cc @ 1415:f18474c64e72

[project @ 1995-09-15 10:09:57 by jwe]
author jwe
date Fri, 15 Sep 1995 10:13:17 +0000
parents 083787534e18
children 045e70a15a8f
line wrap: on
line diff
--- a/src/sysdep.cc
+++ b/src/sysdep.cc
@@ -89,6 +89,9 @@
 // The floating point format on this system.
 floating_point_format native_float_format = OCTAVE_UNKNOWN_FLT_FMT;
 
+// Nonzero if the machine we are running on is big-endian.
+int octave_words_big_endian;
+
 #if defined (HAVE_FLOATINGPOINT_H)
 #include <floatingpoint.h>
 #endif
@@ -249,6 +252,22 @@
     panic ("unrecognized floating point format!");
 }
 
+static void
+ten_little_endians (void)
+{
+  // Are we little or big endian?  From Harbison & Steele.
+
+  union
+  {
+    long l;
+    char c[sizeof (long)];
+  } u;
+
+  u.l = 1;
+
+  octave_words_big_endian = (u.c[sizeof (long) - 1] == 1);
+}
+
 #if defined (EXCEPTION_IN_MATH)
 extern "C"
 {
@@ -292,6 +311,8 @@
 #endif
 
   octave_ieee_init ();
+
+  ten_little_endians ();
 }
 
 // Set terminal in raw mode.  From less-177.