aclocal.float.m4 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # AX_C_FLOAT_WORDS_BIGENDIAN ([ACTION-IF-TRUE], [ACTION-IF-FALSE],
  2. # [ACTION-IF-UNKNOWN])
  3. #
  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, [
  14. # The endianess is detected by first compiling C code that contains a special
  15. # double float value, then grepping the resulting object file for certain
  16. # strings of ascii values. The double is specially crafted to have a
  17. # binary representation that corresponds with a simple string. In this
  18. # implementation, the string "noonsees" was selected because the individual
  19. # word values ("noon" and "sees") are palindromes, thus making this test
  20. # byte-order agnostic. If grep finds the string "noonsees" in the object
  21. # file, the target platform stores float words in big-endian order. If grep
  22. # finds "seesnoon", float words are in little-endian order. If neither value
  23. # is found, the user is instructed to specify the ordering.
  24. ax_cv_c_float_words_bigendian=unknown
  25. AC_LINK_IFELSE([AC_LANG_SOURCE([[
  26. double d __attribute__((used)) = 90904234967036810337470478905505011476211692735615632014797120844053488865816695273723469097858056257517020191247487429516932130503560650002327564517570778480236724525140520121371739201496540132640109977779420565776568942592.0;
  27. int main() { return 0; }
  28. ]])], [
  29. if strings -a conftest$ac_exeext | grep noonsees >/dev/null ; then
  30. ax_cv_c_float_words_bigendian=yes
  31. fi
  32. if strings -a conftest$ac_exeext | grep seesnoon >/dev/null ; then
  33. if test "$ax_cv_c_float_words_bigendian" = unknown; then
  34. ax_cv_c_float_words_bigendian=no
  35. else
  36. ax_cv_c_float_words_bigendian=unknown
  37. fi
  38. fi
  39. ])])
  40. case $ax_cv_c_float_words_bigendian in
  41. yes)
  42. m4_default([$1],
  43. [AC_DEFINE([FLOAT_WORDS_BIGENDIAN], 1,
  44. [Define to 1 if your system stores words within floats
  45. with the most significant word first])]) ;;
  46. no)
  47. $2 ;;
  48. *)
  49. m4_default([$3],
  50. [AC_MSG_ERROR([
  51. Unknown float word ordering. You need to manually preset
  52. ax_cv_c_float_words_bigendian=no (or yes) according to your system.
  53. ])]) ;;
  54. esac
  55. ])# AX_C_FLOAT_WORDS_BIGENDIAN