0001-Add-autoconf-macro-AX_C_FLOAT_WORDS_BIGENDIAN.patch 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. From nobody Mon Sep 17 00:00:00 2001
  2. From: Dan Amelang <dan@amelang.net>
  3. Date: Sun Oct 29 21:30:08 2006 -0800
  4. Subject: [PATCH] Add autoconf macro AX_C_FLOAT_WORDS_BIGENDIAN
  5. The symbol that this macro defines (FLOAT_WORDS_BIGENDIAN) can be used
  6. to make double arithmetic tricks portable.
  7. ---
  8. acinclude.m4 | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  9. configure.in | 1 +
  10. 2 files changed, 66 insertions(+), 0 deletions(-)
  11. 3231d91b59a6c2e1c40bbaa8b143694b6c693662
  12. diff --git a/acinclude.m4 b/acinclude.m4
  13. index af73800..a0eb13a 100644
  14. --- a/acinclude.m4
  15. +++ b/acinclude.m4
  16. @@ -51,3 +51,68 @@ ifelse([$1],[],,
  17. AM_CONDITIONAL(ENABLE_GTK_DOC, test x$enable_gtk_doc = xyes)
  18. AM_CONDITIONAL(GTK_DOC_USE_LIBTOOL, test -n "$LIBTOOL")
  19. ])
  20. +
  21. +# AX_C_FLOAT_WORDS_BIGENDIAN ([ACTION-IF-TRUE], [ACTION-IF-FALSE],
  22. +# [ACTION-IF-UNKNOWN])
  23. +#
  24. +# Checks the ordering of words within a multi-word float. This check
  25. +# is necessary because on some systems (e.g. certain ARM systems), the
  26. +# float word ordering can be different from the byte ordering. In a
  27. +# multi-word float context, "big-endian" implies that the word containing
  28. +# the sign bit is found in the memory location with the lowest address.
  29. +# This implemenation was inspired by the AC_C_BIGENDIAN macro in autoconf.
  30. +# -------------------------------------------------------------------------
  31. +AC_DEFUN([AX_C_FLOAT_WORDS_BIGENDIAN],
  32. + [AC_CACHE_CHECK(whether float word ordering is bigendian,
  33. + ax_cv_c_float_words_bigendian, [
  34. +
  35. +# The endianess is detected by first compiling C code that contains a special
  36. +# double float value, then grepping the resulting object file for certain
  37. +# strings of ascii values. The double is specially crafted to have a
  38. +# binary representation that corresponds with a simple string. In this
  39. +# implementation, the string "noonsees" was selected because the individual
  40. +# word values ("noon" and "sees") are palindromes, thus making this test
  41. +# byte-order agnostic. If grep finds the string "noonsees" in the object
  42. +# file, the target platform stores float words in big-endian order. If grep
  43. +# finds "seesnoon", float words are in little-endian order. If neither value
  44. +# is found, the user is instructed to specify the ordering.
  45. +
  46. +ax_cv_c_float_words_bigendian=unknown
  47. +AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  48. +
  49. +double d = 90904234967036810337470478905505011476211692735615632014797120844053488865816695273723469097858056257517020191247487429516932130503560650002327564517570778480236724525140520121371739201496540132640109977779420565776568942592.0;
  50. +
  51. +]])], [
  52. +
  53. +if grep noonsees conftest.$ac_objext >/dev/null ; then
  54. + ax_cv_c_float_words_bigendian=yes
  55. +fi
  56. +if grep seesnoon conftest.$ac_objext >/dev/null ; then
  57. + if test "$ax_cv_c_float_words_bigendian" = unknown; then
  58. + ax_cv_c_float_words_bigendian=no
  59. + else
  60. + ax_cv_c_float_words_bigendian=unknown
  61. + fi
  62. +fi
  63. +
  64. +])])
  65. +
  66. +case $ax_cv_c_float_words_bigendian in
  67. + yes)
  68. + m4_default([$1],
  69. + [AC_DEFINE([FLOAT_WORDS_BIGENDIAN], 1,
  70. + [Define to 1 if your system stores words within floats
  71. + with the most significant word first])]) ;;
  72. + no)
  73. + $2 ;;
  74. + *)
  75. + m4_default([$3],
  76. + [AC_MSG_ERROR([
  77. +
  78. +Unknown float word ordering. You need to manually preset
  79. +ax_cv_c_float_words_bigendian=no (or yes) according to your system.
  80. +
  81. + ])]) ;;
  82. +esac
  83. +
  84. +])# AX_C_FLOAT_WORDS_BIGENDIAN
  85. diff --git a/configure.in b/configure.in
  86. index 2d2bf9f..797c7ce 100644
  87. --- a/configure.in
  88. +++ b/configure.in
  89. @@ -55,6 +55,7 @@ AC_PROG_CPP
  90. AC_PROG_LIBTOOL dnl required version (1.4) DON'T REMOVE!
  91. AC_STDC_HEADERS
  92. AC_C_BIGENDIAN
  93. +AX_C_FLOAT_WORDS_BIGENDIAN
  94. dnl ===========================================================================
  95. dnl === Local macros
  96. --
  97. 1.2.6