diff options
author | Herbert Valerio Riedel <hvr@gnu.org> | 2014-01-16 21:39:06 +0100 |
---|---|---|
committer | Herbert Valerio Riedel <hvr@gnu.org> | 2014-01-16 21:39:06 +0100 |
commit | e0b3a05ae4a9b8287e6c8babccf5a4bee8eb35b9 (patch) | |
tree | f8fda68bd3b6f3c780709bc0b04dcf3e0ba35906 /libraries/integer-gmp/cbits | |
parent | 80c8c8c397f22700ee288b93bc3b3594f9e36643 (diff) | |
download | haskell-e0b3a05ae4a9b8287e6c8babccf5a4bee8eb35b9.tar.gz |
Introduce new SIZEOF_MP_LIMB_T derived constant
This allows to simplify code in `float.c` and to encode the
"sizeof(mp_limb_t) != sizeof(W_)" assumption as a compile-time
assertion.
Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
Diffstat (limited to 'libraries/integer-gmp/cbits')
-rw-r--r-- | libraries/integer-gmp/cbits/float.c | 11 | ||||
-rw-r--r-- | libraries/integer-gmp/cbits/gmp-wrappers.cmm | 4 |
2 files changed, 6 insertions, 9 deletions
diff --git a/libraries/integer-gmp/cbits/float.c b/libraries/integer-gmp/cbits/float.c index ec2ec13432..73a89f577a 100644 --- a/libraries/integer-gmp/cbits/float.c +++ b/libraries/integer-gmp/cbits/float.c @@ -11,6 +11,7 @@ /* #include "PosixSource.h" */ #include "Rts.h" #include "gmp.h" +#include "GmpDerivedConstants.h" #include <math.h> @@ -21,15 +22,7 @@ * (lib/fltcode.c). */ -#ifdef _SHORT_LIMB -#define SIZEOF_LIMB_T SIZEOF_UNSIGNED_INT -#else -#ifdef _LONG_LONG_LIMB -#define SIZEOF_LIMB_T SIZEOF_UNSIGNED_LONG_LONG -#else -#define SIZEOF_LIMB_T SIZEOF_UNSIGNED_LONG -#endif -#endif +#define SIZEOF_LIMB_T SIZEOF_MP_LIMB_T #if SIZEOF_LIMB_T == 4 #define GMP_BASE 4294967296.0 diff --git a/libraries/integer-gmp/cbits/gmp-wrappers.cmm b/libraries/integer-gmp/cbits/gmp-wrappers.cmm index eb555fd382..4c7df574e7 100644 --- a/libraries/integer-gmp/cbits/gmp-wrappers.cmm +++ b/libraries/integer-gmp/cbits/gmp-wrappers.cmm @@ -80,6 +80,10 @@ import "rts" stg_INTLIKE_closure; the case for all the platforms that GHC supports, currently. -------------------------------------------------------------------------- */ +#if SIZEOF_MP_LIMB_T != SIZEOF_W +#error "sizeof(mp_limb_t) != sizeof(W_)" +#endif + /* This is used when a dummy pointer is needed for a ByteArray# return value Ideally this would be a statically allocated 'ByteArray#' |