This is the mail archive of the automake@gnu.org mailing list for the automake project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: macro for IEEE-754 Floating-Point compliancy ?


Sebastien Barre <Sebastien.Barre@utc.fr> writes:

   I was wondering if anyone ever wrote a macro that could determine if the
   host computer is using the "IEEE-754 Floating-Point" representation for its
   internal floating point numbers.

I once used a macro for this, but it failed for undetermined reasons
on certain m68k machines, and I was never able to figure out why,
because the machine was so slow and the connection was so laggy.
Here's the excerpt from my current configure.in (this is from GNU
PSPP).  You'll want to uncomment everything, of course:

dnl There used to be a check for floating-point representation here, but
dnl for some reason it didn't work on certain m68k GNU/Linux machines, and
dnl I was unable to determine why.  So, since every modern computer uses
dnl ieee754 format anyway, I've hard-coded it to ieee754.  Anyone who uses
dnl something else can enumerate the exceptions.

AC_DEFINE(FPREP, FPREP_IEEE754)

dnl if test "$cross_compiling" = yes; then
dnl   AC_MSG_WARN([Edit config.h to set proper values for SIZEOF_SHORT, \
dnl SIZEOF_INT,])
dnl   AC_MSG_WARN([SIZEOF_LONG, and SIZEOF_LONG_LONG (if available), if the \
dnl values])
dnl   AC_MSG_WARN([are not 2, 4, 4, and 8, respectively.])
dnl   AC_MSG_WARN([Also set the floating point representation (IEEE754, etc.).])
dnl else
dnl   AC_CACHE_CHECK(
dnl       floating point representation, ac_cv_sys_fprep,
dnl 
dnl       AC_TRY_RUN(
dnl             [changequote(<<, >>)dnl
dnl             <<
dnl 	      main () {
dnl 	      /* Test for IEEE754 floating point representation. */
dnl 	      union { unsigned char c[8]; double d; }
dnl 		l = {{0x1c, 0xbc, 0x6e, 0xf2, 0x54, 0x8b, 0x11, 0x43}},
dnl 		b = {{0x43, 0x11, 0x8b, 0x54, 0xf2, 0x6e, 0xbc, 0x1c}};
dnl 	      return l.d!=1234567891234567.0 && b.d!=1234567891234567.0;
dnl 	      }
dnl             >>
dnl             changequote([, ])dnl
dnl             ], ac_cv_sys_fprep=ieee754, ac_cv_sys_fprep=unknown,
dnl 	    AC_MSG_WARN([This error cannot occur.])))
dnl   if test "$ac_cv_sys_fprep" = ieee754; then
dnl     AC_DEFINE(FPREP, FPREP_IEEE754)
dnl   else
dnl     AC_MSG_WARN([Unknown floating-point representation.  This is a serious \
dnl error.])
dnl     AC_MSG_WARN([Please contact the author for porting information.])
dnl     AC_MSG_WARN([(It should be a fairly simple port, by the way.)])
dnl     AC_DEFINE(FPREP, FPREP_UNKNOWN)
dnl   fi
dnl fi

-- 
"...dans ce pays-ci il est bon de tuer de temps en temps un amiral
 pour encourager les autres."
--Voltaire, _Candide_


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]