1 # AX_C_FLOAT_WORDS_BIGENDIAN ([ACTION-IF-TRUE], [ACTION-IF-FALSE],
4 # Checks the ordering of words within a multi-word float. This check
5 # is necessary because on some systems (e.g. certain ARM systems), the
6 # float word ordering can be different from the byte ordering. In a
7 # multi-word float context, "big-endian" implies that the word containing
8 # the sign bit is found in the memory location with the lowest address.
9 # This implemenation was inspired by the AC_C_BIGENDIAN macro in autoconf.
10 # -------------------------------------------------------------------------
11 AC_DEFUN([AX_C_FLOAT_WORDS_BIGENDIAN],
12 [AC_CACHE_CHECK(whether float word ordering is bigendian,
13 ax_cv_c_float_words_bigendian, [
15 # The endianess is detected by first compiling C code that contains a special
16 # double float value, then grepping the resulting object file for certain
17 # strings of ascii values. The double is specially crafted to have a
18 # binary representation that corresponds with a simple string. In this
19 # implementation, the string "noonsees" was selected because the individual
20 # word values ("noon" and "sees") are palindromes, thus making this test
21 # byte-order agnostic. If grep finds the string "noonsees" in the object
22 # file, the target platform stores float words in big-endian order. If grep
23 # finds "seesnoon", float words are in little-endian order. If neither value
24 # is found, the user is instructed to specify the ordering.
26 ax_cv_c_float_words_bigendian=unknown
27 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
29 double d = 90904234967036810337470478905505011476211692735615632014797120844053488865816695273723469097858056257517020191247487429516932130503560650002327564517570778480236724525140520121371739201496540132640109977779420565776568942592.0;
33 if strings - conftest.$ac_objext | grep noonsees >/dev/null ; then
34 ax_cv_c_float_words_bigendian=yes
36 if strings - conftest.$ac_objext | grep seesnoon >/dev/null ; then
37 if test "$ax_cv_c_float_words_bigendian" = unknown; then
38 ax_cv_c_float_words_bigendian=no
40 ax_cv_c_float_words_bigendian=unknown
46 case $ax_cv_c_float_words_bigendian in
49 [AC_DEFINE([FLOAT_WORDS_BIGENDIAN], 1,
50 [Define to 1 if your system stores words within floats
51 with the most significant word first])]) ;;
58 Unknown float word ordering. You need to manually preset
59 ax_cv_c_float_words_bigendian=no (or yes) according to your system.
64 ])# AX_C_FLOAT_WORDS_BIGENDIAN