Commit 51f782f4 authored by Ian Lynagh's avatar Ian Lynagh

Cope with big endian float word order on little endian machines

parent d9dff2f7
......@@ -4,6 +4,33 @@
# ensure we don't clash with any pre-supplied autoconf ones.
# FPTOOLS_FLOAT_WORD_ORDER_BIGENDIAN
# ----------------------------------
# Little endian Arm on Linux with some ABIs has big endian word order
# in doubles. Define FLOAT_WORDS_BIGENDIAN if this is the case.
AC_DEFUN([FPTOOLS_FLOAT_WORD_ORDER_BIGENDIAN],
[AC_CACHE_CHECK([whether float word order is big endian], [fptools_cv_float_word_order_bigendian],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[#include <endian.h>],
[#if defined(__FLOAT_WORD_ORDER) && __FLOAT_WORD_ORDER == BIG_ENDIAN
return 0;
#else
not float word order big endian
#endif]
)],
[fptools_cv_float_word_order_bigendian=yes],
[fptools_cv_float_word_order_bigendian=no])
])
case $fptools_cv_float_word_order_bigendian in
yes)
AC_DEFINE([FLOAT_WORDS_BIGENDIAN], 1,
[Define to 1 if your processor stores words of floats with
the most significant byte first]) ;;
esac
])
# FP_EVAL_STDERR(COMMAND)
# -----------------------
# Eval COMMAND, save its stderr (without lines resulting from shell tracing)
......
......@@ -1136,6 +1136,7 @@ AC_C_CONST
dnl ** are we big endian?
AC_C_BIGENDIAN
FPTOOLS_FLOAT_WORD_ORDER_BIGENDIAN
dnl ** check for leading underscores in symbol names
FP_LEADING_UNDERSCORE
......
......@@ -48,7 +48,7 @@
#define FMSBIT 0x80000000
#endif
#ifdef WORDS_BIGENDIAN
#if defined(WORDS_BIGENDIAN) || defined(FLOAT_WORDS_BIGENDIAN)
#define L 1
#define H 0
#else
......@@ -306,11 +306,18 @@ union stg_ieee754_dbl
unsigned int exponent:11;
unsigned int mantissa0:20;
unsigned int mantissa1:32;
#else
#if FLOAT_WORDS_BIGENDIAN
unsigned int mantissa0:20;
unsigned int exponent:11;
unsigned int negative:1;
unsigned int mantissa1:32;
#else
unsigned int mantissa1:32;
unsigned int mantissa0:20;
unsigned int exponent:11;
unsigned int negative:1;
#endif
#endif
} ieee;
/* This format makes it easier to see if a NaN is a signalling NaN. */
......@@ -322,12 +329,20 @@ union stg_ieee754_dbl
unsigned int quiet_nan:1;
unsigned int mantissa0:19;
unsigned int mantissa1:32;
#else
#if FLOAT_WORDS_BIGENDIAN
unsigned int mantissa0:19;
unsigned int quiet_nan:1;
unsigned int exponent:11;
unsigned int negative:1;
unsigned int mantissa1:32;
#else
unsigned int mantissa1:32;
unsigned int mantissa0:19;
unsigned int quiet_nan:1;
unsigned int exponent:11;
unsigned int negative:1;
#endif
#endif
} ieee_nan;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment