ieee754 0.7.4 → 0.7.5
raw patch · 3 files changed
+44/−10 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- NEWS +5/−0
- cbits/feqrel_source.c +38/−2
- ieee754.cabal +1/−8
NEWS view
@@ -1,3 +1,8 @@+Changes in 0.7.5:++* Added more robust check for endianness (related to issue #5, reported by @juricast).++ Changes in 0.7.4: * Add C implementation of copysign, copysignf
cbits/feqrel_source.c view
@@ -1,6 +1,42 @@ /* adapted from Tango version 0.99.9, BSD Licensed */ +/* Endianness detection taken from http://esr.ibiblio.org/?p=5095 .+ *+ * We are assuming that the endianness is the same for integers and floats;+ * this is true for modern systems but false in a few historical machines and+ * some old ARM processors; see+ * http://en.wikipedia.org/wiki/Endianness#Floating-point_and_endianness .+ */++/*+ __BIG_ENDIAN__ and __LITTLE_ENDIAN__ are defined in some gcc versions+ only, probably depending on the architecture. Try to use endian.h if+ the gcc way fails - endian.h also does not seem to be available on all+ platforms.+*/+#ifdef __BIG_ENDIAN__+# define WORDS_BIGENDIAN 1+#else /* __BIG_ENDIAN__ */+# ifdef __LITTLE_ENDIAN__+# undef WORDS_BIGENDIAN+# else+# ifdef BSD+# include <sys/endian.h>+# else+# include <endian.h>+# endif+# if __BYTE_ORDER == __BIG_ENDIAN+# define WORDS_BIGENDIAN 1+# elif __BYTE_ORDER == __LITTLE_ENDIAN+# undef WORDS_BIGENDIAN+# else+# error "unable to determine endianess!"+# endif /* __BYTE_ORDER */+# endif /* __LITTLE_ENDIAN__ */+#endif /* __BIG_ENDIAN__ */++ /* REAL_EXPMASK is a ushort mask to select the exponent portion (without sign) * REAL_SIGNMASK is a ushort mask to select the sign bit. * REAL_EXPPOS_SHORT is the index of the exponent when represented as a uint16_t array.@@ -16,7 +52,7 @@ # define REAL_EXPBIAS ((uint16_t) 0x3F00) # define REAL_EXPBIAS_INT32 ((uint32_t) 0x7F800000) # define REAL_MANTISSAMASK_INT32 ((uint32_t) 0x007FFFFF)-# if BIG_ENDIAN == 1+# if WORDS_BIGENDIAN # define REAL_EXPPOS_INT16 0 # else # define REAL_EXPPOS_INT16 1@@ -28,7 +64,7 @@ # define REAL_EXPBIAS ((uint16_t) 0x3FE0) # define REAL_EXPBIAS_INT32 ((uint32_t) 0x7FF00000) # define REAL_MANTISSAMASK_INT32 ((uint32_t) 0x000FFFFF); /* for the MSB only */-# if BIG_ENDIAN == 1+# if WORDS_BIGENDIAN # define REAL_EXPPOS_INT16 0 # define REAL_SIGNPOS_BYTE 0 # else
ieee754.cabal view
@@ -1,5 +1,5 @@ name: ieee754-version: 0.7.4+version: 0.7.5 homepage: http://github.com/patperry/hs-ieee754 synopsis: Utilities for dealing with IEEE floating point numbers description:@@ -19,11 +19,6 @@ extra-source-files: LICENSE.Tango NEWS cbits/feqrel_source.c tests/Makefile tests/Tests.hs -flag big_endian- description: Build for a big endian machine. Beware that only- little endian machines have been tested.- default: False- library exposed-modules: Data.AEq Numeric.IEEE@@ -39,5 +34,3 @@ cbits/double.c cc-options: -Wall --std=c99- if flag(big_endian)- cc-options: -DBIG_ENDIAN